Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.chrome.browser.invalidation; | 5 package org.chromium.chrome.browser.invalidation; |
| 6 | 6 |
| 7 import android.accounts.Account; | 7 import android.accounts.Account; |
| 8 import android.app.Activity; | 8 import android.app.Activity; |
| 9 import android.content.Context; | 9 import android.content.Context; |
| 10 import android.content.Intent; | 10 import android.content.Intent; |
| 11 import android.content.pm.ApplicationInfo; | 11 import android.content.pm.ApplicationInfo; |
| 12 import android.content.pm.PackageInfo; | 12 import android.content.pm.PackageInfo; |
| 13 import android.os.Bundle; | 13 import android.os.Bundle; |
| 14 | 14 |
| 15 import org.junit.Assert; | |
| 16 import org.junit.Before; | |
| 17 import org.junit.Test; | |
| 18 import org.junit.runner.RunWith; | |
| 19 import org.robolectric.Robolectric; | |
| 20 import org.robolectric.Shadows; | |
| 21 import org.robolectric.annotation.Config; | |
| 22 import org.robolectric.res.builder.RobolectricPackageManager; | |
| 23 import org.robolectric.shadows.ShadowActivity; | |
| 24 import org.robolectric.shadows.ShadowLooper; | |
| 25 | |
| 15 import org.chromium.base.ActivityState; | 26 import org.chromium.base.ActivityState; |
| 16 import org.chromium.base.ApplicationState; | 27 import org.chromium.base.ApplicationState; |
| 17 import org.chromium.base.ApplicationStatus; | 28 import org.chromium.base.ApplicationStatus; |
| 18 import org.chromium.base.CollectionUtil; | 29 import org.chromium.base.CollectionUtil; |
| 19 import org.chromium.base.ContextUtils; | 30 import org.chromium.base.ContextUtils; |
| 20 import org.chromium.base.test.util.Feature; | 31 import org.chromium.base.test.util.Feature; |
| 21 import org.chromium.chrome.browser.sync.ProfileSyncService; | 32 import org.chromium.chrome.browser.sync.ProfileSyncService; |
| 22 import org.chromium.components.signin.ChromeSigninController; | 33 import org.chromium.components.signin.ChromeSigninController; |
| 23 import org.chromium.components.sync.AndroidSyncSettings; | 34 import org.chromium.components.sync.AndroidSyncSettings; |
| 24 import org.chromium.components.sync.ModelType; | 35 import org.chromium.components.sync.ModelType; |
| 25 import org.chromium.components.sync.ModelTypeHelper; | 36 import org.chromium.components.sync.ModelTypeHelper; |
| 26 import org.chromium.components.sync.notifier.InvalidationIntentProtocol; | 37 import org.chromium.components.sync.notifier.InvalidationIntentProtocol; |
| 27 import org.chromium.components.sync.test.util.MockSyncContentResolverDelegate; | 38 import org.chromium.components.sync.test.util.MockSyncContentResolverDelegate; |
| 28 import org.chromium.testing.local.CustomShadowAsyncTask; | 39 import org.chromium.testing.local.CustomShadowAsyncTask; |
| 29 import org.chromium.testing.local.LocalRobolectricTestRunner; | 40 import org.chromium.testing.local.LocalRobolectricTestRunner; |
| 30 import org.junit.Assert; | |
| 31 import org.junit.Before; | |
| 32 import org.junit.Test; | |
| 33 import org.junit.runner.RunWith; | |
| 34 import org.robolectric.Robolectric; | |
| 35 import org.robolectric.Shadows; | |
| 36 import org.robolectric.annotation.Config; | |
| 37 import org.robolectric.res.builder.RobolectricPackageManager; | |
| 38 import org.robolectric.shadows.ShadowActivity; | |
| 39 import org.robolectric.shadows.ShadowLooper; | |
| 40 | 41 |
| 41 import java.util.HashSet; | 42 import java.util.HashSet; |
| 42 import java.util.Set; | 43 import java.util.Set; |
| 43 import java.util.concurrent.atomic.AtomicBoolean; | 44 import java.util.concurrent.atomic.AtomicBoolean; |
| 44 | 45 |
| 45 /** | 46 /** |
| 46 * Tests for the {@link InvalidationController}. | 47 * Tests for the {@link InvalidationController}. |
| 47 */ | 48 */ |
| 48 @RunWith(LocalRobolectricTestRunner.class) | 49 @RunWith(LocalRobolectricTestRunner.class) |
| 49 @Config(manifest = Config.NONE, shadows = {CustomShadowAsyncTask.class}) | 50 @Config(manifest = Config.NONE, shadows = {CustomShadowAsyncTask.class}, sdk = 2 1) |
|
jbudorick
2017/03/13 22:36:54
super-nit: You have sdk before shadows in some cas
mikecase (-- gone --)
2017/03/14 18:08:39
Done
| |
| 50 public class InvalidationControllerTest { | 51 public class InvalidationControllerTest { |
| 51 /** | 52 /** |
| 52 * Stubbed out ProfileSyncService with a setter to control return value of | 53 * Stubbed out ProfileSyncService with a setter to control return value of |
| 53 * {@link ProfileSyncService#getPreferredDataTypes()} | 54 * {@link ProfileSyncService#getPreferredDataTypes()} |
| 54 */ | 55 */ |
| 55 private static class ProfileSyncServiceStub extends ProfileSyncService { | 56 private static class ProfileSyncServiceStub extends ProfileSyncService { |
| 56 private Set<Integer> mPreferredDataTypes; | 57 private Set<Integer> mPreferredDataTypes; |
| 57 | 58 |
| 58 public ProfileSyncServiceStub() { | 59 public ProfileSyncServiceStub() { |
| 59 super(); | 60 super(); |
| (...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 497 * intent. | 498 * intent. |
| 498 */ | 499 */ |
| 499 private static Set<String> getRegisterIntentRegisterTypes(Intent intent) { | 500 private static Set<String> getRegisterIntentRegisterTypes(Intent intent) { |
| 500 Set<String> registeredTypes = new HashSet<String>(); | 501 Set<String> registeredTypes = new HashSet<String>(); |
| 501 registeredTypes.addAll( | 502 registeredTypes.addAll( |
| 502 intent.getStringArrayListExtra(InvalidationIntentProtocol.EXTRA_ REGISTERED_TYPES)); | 503 intent.getStringArrayListExtra(InvalidationIntentProtocol.EXTRA_ REGISTERED_TYPES)); |
| 503 return registeredTypes; | 504 return registeredTypes; |
| 504 } | 505 } |
| 505 | 506 |
| 506 } | 507 } |
| OLD | NEW |