Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(535)

Unified Diff: components/policy/android/junit/src/org/chromium/policy/AbstractAppRestrictionsProviderTest.java

Issue 2322963002: Remove the Android policy cache (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/policy/android/java/src/org/chromium/policy/AbstractAppRestrictionsProvider.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/policy/android/junit/src/org/chromium/policy/AbstractAppRestrictionsProviderTest.java
diff --git a/components/policy/android/junit/src/org/chromium/policy/AbstractAppRestrictionsProviderTest.java b/components/policy/android/junit/src/org/chromium/policy/AbstractAppRestrictionsProviderTest.java
index d556ef02d413459e4937aecc53fe33c7476cec06..aa5a56cbc1181567d0345a841bc193c9b15e209f 100644
--- a/components/policy/android/junit/src/org/chromium/policy/AbstractAppRestrictionsProviderTest.java
+++ b/components/policy/android/junit/src/org/chromium/policy/AbstractAppRestrictionsProviderTest.java
@@ -4,16 +4,11 @@
package org.chromium.policy;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyBoolean;
-import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -30,7 +25,6 @@ import org.robolectric.Robolectric;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
import org.robolectric.shadows.ShadowApplication;
-import org.robolectric.shadows.ShadowLooper;
import java.util.concurrent.Executor;
@@ -95,8 +89,6 @@ public class AbstractAppRestrictionsProviderTest {
// Mock out the histogram functions, since they call statics.
AbstractAppRestrictionsProvider provider = spy(new DummyAppRestrictionsProvider(context));
- provider.setTaskExecutor(new TestExecutor());
- doNothing().when(provider).recordCacheLoadResultHistogram(anyBoolean());
doNothing().when(provider).recordStartTimeHistogram(anyLong());
// Set up the buffer to be returned by getApplicationRestrictions.
@@ -106,32 +98,10 @@ public class AbstractAppRestrictionsProviderTest {
CombinedPolicyProvider combinedProvider = mock(CombinedPolicyProvider.class);
provider.setManagerAndSource(combinedProvider, 0);
- // Refresh with no cache should do nothing immediately.
provider.refresh();
- verify(combinedProvider, never()).onSettingsAvailable(anyInt(), any(Bundle.class));
-
- // Let the Async task run and return its result.
- Robolectric.getBackgroundThreadScheduler().advanceBy(0);
- // The AsyncTask should now have got the restrictions.
verify(provider).getApplicationRestrictions(anyString());
verify(provider).recordStartTimeHistogram(anyLong());
-
- ShadowLooper.runUiThreadTasks();
- // The policies should now have been set.
verify(combinedProvider).onSettingsAvailable(0, b1);
-
- // On next refresh onSettingsAvailable should be called twice, once with the current buffer
- // and once with the new data.
- Bundle b2 = new Bundle();
- b2.putString("Key1", "value1");
- b2.putInt("Key2", 84);
- when(provider.getApplicationRestrictions(anyString())).thenReturn(b2);
-
- provider.refresh();
- verify(combinedProvider, times(2)).onSettingsAvailable(0, b1);
- Robolectric.getBackgroundThreadScheduler().advanceBy(0);
- ShadowLooper.runUiThreadTasks();
- verify(combinedProvider).onSettingsAvailable(0, b2);
}
/**
« no previous file with comments | « components/policy/android/java/src/org/chromium/policy/AbstractAppRestrictionsProvider.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698