Home | History | Annotate | Download | only in cts
      1 /*
      2  * Copyright (C) 2008 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 package android.view.inputmethod.cts;
     17 
     18 
     19 import android.os.Parcel;
     20 import android.test.AndroidTestCase;
     21 import android.view.inputmethod.ExtractedText;
     22 
     23 public class ExtractedTextTest extends AndroidTestCase {
     24 
     25     public void testWriteToParcel() {
     26 
     27         ExtractedText extractedText = new ExtractedText();
     28         extractedText.flags = 1;
     29         extractedText.selectionEnd = 11;
     30         extractedText.selectionStart = 2;
     31         extractedText.startOffset = 1;
     32         CharSequence text = "test";
     33         extractedText.text = text;
     34         Parcel p = Parcel.obtain();
     35         extractedText.writeToParcel(p, 0);
     36         p.setDataPosition(0);
     37         ExtractedText target = ExtractedText.CREATOR.createFromParcel(p);
     38         assertEquals(extractedText.flags, target.flags);
     39         assertEquals(extractedText.selectionEnd, target.selectionEnd);
     40         assertEquals(extractedText.selectionStart, target.selectionStart);
     41         assertEquals(extractedText.startOffset, target.startOffset);
     42         assertEquals(extractedText.partialStartOffset, target.partialStartOffset);
     43         assertEquals(extractedText.partialEndOffset, target.partialEndOffset);
     44         assertEquals(extractedText.text.toString(), target.text.toString());
     45 
     46         assertEquals(0, extractedText.describeContents());
     47     }
     48 }
     49