Xi Chen | a455bd5 | 2016-07-25 17:00:22 -0700 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (C) 2016 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 com.android.contacts.util; |
| 17 | |
| 18 | import android.accounts.Account; |
| 19 | import android.test.AndroidTestCase; |
| 20 | import android.test.suitebuilder.annotation.SmallTest; |
| 21 | |
| 22 | import java.util.ArrayList; |
| 23 | import java.util.List; |
| 24 | |
| 25 | /** |
| 26 | * Tests for SyncUtil. |
| 27 | */ |
| 28 | @SmallTest |
| 29 | public class SyncUtilTests extends AndroidTestCase { |
| 30 | private static final String TAG = "SyncUtilTests"; |
| 31 | |
| 32 | private static final String GOOGLE_TYPE = "com.google"; |
| 33 | private static final String NOT_GOOGLE_TYPE = "com.abc"; |
| 34 | private static final String ACCOUNT_NAME = "ACCOUNT_NAME"; |
| 35 | |
| 36 | private final Account mGoogleAccount; |
| 37 | private final Account mOtherAccount; |
| 38 | |
| 39 | public SyncUtilTests() { |
| 40 | mGoogleAccount = new Account(ACCOUNT_NAME, GOOGLE_TYPE); |
| 41 | mOtherAccount = new Account(ACCOUNT_NAME, NOT_GOOGLE_TYPE); |
| 42 | } |
| 43 | |
| 44 | public void testIsUnsyncableGoogleAccount() throws Exception { |
| 45 | // The account names of mGoogleAccount and mOtherAccount are not valid, so both accounts |
| 46 | // are not syncable. |
| 47 | assertTrue(SyncUtil.isUnsyncableGoogleAccount(mGoogleAccount)); |
| 48 | assertFalse(SyncUtil.isUnsyncableGoogleAccount(mOtherAccount)); |
| 49 | assertFalse(SyncUtil.isUnsyncableGoogleAccount(null)); |
| 50 | } |
| 51 | } |