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 21 import androidx.test.filters.SmallTest; 22 23 /** 24 * Tests for SyncUtil. 25 */ 26 @SmallTest 27 public class SyncUtilTests extends AndroidTestCase { 28 private static final String TAG = "SyncUtilTests"; 29 30 private static final String GOOGLE_TYPE = "com.google"; 31 private static final String NOT_GOOGLE_TYPE = "com.abc"; 32 private static final String ACCOUNT_NAME = "ACCOUNT_NAME"; 33 34 private final Account mGoogleAccount; 35 private final Account mOtherAccount; 36 SyncUtilTests()37 public SyncUtilTests() { 38 mGoogleAccount = new Account(ACCOUNT_NAME, GOOGLE_TYPE); 39 mOtherAccount = new Account(ACCOUNT_NAME, NOT_GOOGLE_TYPE); 40 } 41 testIsUnsyncableGoogleAccount()42 public void testIsUnsyncableGoogleAccount() throws Exception { 43 // The account names of mGoogleAccount and mOtherAccount are not valid, so both accounts 44 // are not syncable. 45 assertTrue(SyncUtil.isUnsyncableGoogleAccount(mGoogleAccount)); 46 assertFalse(SyncUtil.isUnsyncableGoogleAccount(mOtherAccount)); 47 assertFalse(SyncUtil.isUnsyncableGoogleAccount(null)); 48 } 49 } 50