Home | History | Annotate | Download | only in cts
      1 package android.accounts.cts;
      2 
      3 import android.accounts.Account;
      4 import android.os.Parcel;
      5 
      6 import junit.framework.TestCase;
      7 
      8 public class AccountTest extends TestCase {
      9 
     10     private Account account;
     11 
     12     @Override
     13     public void setUp() throws Exception {
     14         account = new Account("abc (at) xyz.org", "com.my.auth");
     15     }
     16 
     17     public void testAccountObjectCreationWithNullName() {
     18         try {
     19             new Account(null, "com.my.auth");
     20             fail();
     21         } catch (IllegalArgumentException expectedException) {
     22         }
     23     }
     24 
     25     public void testAccountObjectCreationWithNullAccountType() {
     26         try {
     27             new Account("abc (at) xyz.org", null);
     28             fail();
     29         } catch (IllegalArgumentException expectedException) {
     30         }
     31     }
     32 
     33     public void testDescribeContents() {
     34         assertEquals(0, account.describeContents());
     35     }
     36 
     37     public void testWriteToParcel() {
     38         Parcel parcel = Parcel.obtain();
     39         parcel.setDataPosition(0);
     40         account.writeToParcel(parcel, 0);
     41         // Reset the position to initial.
     42         parcel.setDataPosition(0);
     43         // Create a new account object from just populated parcel,
     44         // and verify it is equivalent to the original account.
     45         Account newAccount = new Account(parcel);
     46         assertEquals(account, newAccount);
     47 
     48         parcel.recycle();
     49     }
     50 
     51 }
     52