Home | History | Annotate | Download | only in content
      1 /*
      2  * Copyright (C) 2010 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 
     17 package android.content;
     18 
     19 import android.accounts.Account;
     20 import android.os.Bundle;
     21 import android.test.AndroidTestCase;
     22 import android.test.suitebuilder.annotation.SmallTest;
     23 
     24 /**
     25  * You can run those tests with:
     26  *
     27  * adb shell am instrument
     28  * -e debug false
     29  * -w
     30  * -e class android.content.SyncOperationTest com.android.frameworks.coretests/android.test.InstrumentationTestRunner
     31  */
     32 
     33 public class SyncOperationTest extends AndroidTestCase {
     34 
     35     @SmallTest
     36     public void testToKey() {
     37         Account account1 = new Account("account1", "type1");
     38         Account account2 = new Account("account2", "type2");
     39 
     40         Bundle b1 = new Bundle();
     41         Bundle b2 = new Bundle();
     42         b2.putBoolean("b2", true);
     43 
     44         SyncOperation op1 = new SyncOperation(account1, 0,
     45                 1,
     46                 "authority1",
     47                 b1,
     48                 100,
     49                 1000,
     50                 10000,
     51                 false);
     52 
     53         // Same as op1 but different time infos
     54         SyncOperation op2 = new SyncOperation(account1, 0,
     55                 1,
     56                 "authority1",
     57                 b1,
     58                 200,
     59                 2000,
     60                 20000,
     61                 false);
     62 
     63         // Same as op1 but different authority
     64         SyncOperation op3 = new SyncOperation(account1, 0,
     65                 1,
     66                 "authority2",
     67                 b1,
     68                 100,
     69                 1000,
     70                 10000,
     71                 false);
     72 
     73         // Same as op1 but different account
     74         SyncOperation op4 = new SyncOperation(account2, 0,
     75                 1,
     76                 "authority1",
     77                 b1,
     78                 100,
     79                 1000,
     80                 10000,
     81                 false);
     82 
     83         // Same as op1 but different bundle
     84         SyncOperation op5 = new SyncOperation(account1, 0,
     85                 1,
     86                 "authority1",
     87                 b2,
     88                 100,
     89                 1000,
     90                 10000,
     91                 false);
     92 
     93         assertEquals(op1.key, op2.key);
     94         assertNotSame(op1.key, op3.key);
     95         assertNotSame(op1.key, op4.key);
     96         assertNotSame(op1.key, op5.key);
     97     }
     98 }
     99