| 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.superviseduser; | 5 package org.chromium.chrome.browser.superviseduser; |
| 6 | 6 |
| 7 import android.accounts.Account; | 7 import android.accounts.Account; |
| 8 import android.content.ContentProviderClient; | 8 import android.content.ContentProviderClient; |
| 9 import android.content.ContentResolver; | 9 import android.content.ContentResolver; |
| 10 import android.database.Cursor; | 10 import android.database.Cursor; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 PrefServiceBridge.getInstance().setSupervisedUserId(""); | 86 PrefServiceBridge.getInstance().setSupervisedUserId(""); |
| 87 return ChildAccountService.isChildAccount(); | 87 return ChildAccountService.isChildAccount(); |
| 88 } | 88 } |
| 89 | 89 |
| 90 })); | 90 })); |
| 91 ContentProviderClient client = mResolver.acquireContentProviderClient(mA
uthority); | 91 ContentProviderClient client = mResolver.acquireContentProviderClient(mA
uthority); |
| 92 assertNotNull(client); | 92 assertNotNull(client); |
| 93 SupervisedUserContentProvider.enableContentProviderForTesting(); | 93 SupervisedUserContentProvider.enableContentProviderForTesting(); |
| 94 Cursor cursor = client.query(mUri, null, "url = 'http://google.com'", nu
ll, null); | 94 Cursor cursor = client.query(mUri, null, "url = 'http://google.com'", nu
ll, null); |
| 95 assertNotNull(cursor); | 95 assertNotNull(cursor); |
| 96 assertEquals(WebRestrictionsContentProvider.PROCEED, cursor.getInt(0)); | 96 assertEquals(WebRestrictionsContentProvider.BLOCKED, cursor.getInt(0)); |
| 97 cursor = client.query(mUri, null, "url = 'http://www.notgoogle.com'", nu
ll, null); | 97 cursor = client.query(mUri, null, "url = 'http://www.notgoogle.com'", nu
ll, null); |
| 98 assertNotNull(cursor); | 98 assertNotNull(cursor); |
| 99 assertEquals(WebRestrictionsContentProvider.PROCEED, cursor.getInt(0)); | 99 assertEquals(WebRestrictionsContentProvider.BLOCKED, cursor.getInt(0)); |
| 100 } | 100 } |
| 101 | 101 |
| 102 @SmallTest | 102 @SmallTest |
| 103 public void testWithSupervisedUser() throws RemoteException, ExecutionExcept
ion { | 103 public void testWithSupervisedUser() throws RemoteException, ExecutionExcept
ion { |
| 104 final Account account = SigninTestUtil.addAndSignInTestAccount(); | 104 final Account account = SigninTestUtil.addAndSignInTestAccount(); |
| 105 assertNotNull(account); | 105 assertNotNull(account); |
| 106 assertTrue(ThreadUtils.runOnUiThreadBlocking(new Callable<Boolean>() { | 106 assertTrue(ThreadUtils.runOnUiThreadBlocking(new Callable<Boolean>() { |
| 107 | 107 |
| 108 @Override | 108 @Override |
| 109 public Boolean call() throws Exception { | 109 public Boolean call() throws Exception { |
| 110 PrefServiceBridge.getInstance().setSupervisedUserId("ChildAccoun
tSUID"); | 110 PrefServiceBridge.getInstance().setSupervisedUserId("ChildAccoun
tSUID"); |
| 111 return ChildAccountService.isChildAccount(); | 111 return ChildAccountService.isChildAccount(); |
| 112 } | 112 } |
| 113 | 113 |
| 114 })); | 114 })); |
| 115 ContentProviderClient client = mResolver.acquireContentProviderClient(mA
uthority); | 115 ContentProviderClient client = mResolver.acquireContentProviderClient(mA
uthority); |
| 116 assertNotNull(client); | 116 assertNotNull(client); |
| 117 SupervisedUserContentProvider.enableContentProviderForTesting(); | 117 SupervisedUserContentProvider.enableContentProviderForTesting(); |
| 118 // setFilter for testing sets a default filter that blocks by default. | 118 // setFilter for testing sets a default filter that blocks by default. |
| 119 mResolver.call(mUri, "setFilterForTesting", null, null); | 119 mResolver.call(mUri, "setFilterForTesting", null, null); |
| 120 Cursor cursor = client.query(mUri, null, "url = 'http://www.google.com'"
, null, null); | 120 Cursor cursor = client.query(mUri, null, "url = 'http://www.google.com'"
, null, null); |
| 121 assertNotNull(cursor); | 121 assertNotNull(cursor); |
| 122 assertEquals(WebRestrictionsContentProvider.BLOCKED, cursor.getInt(0)); | 122 assertEquals(WebRestrictionsContentProvider.BLOCKED, cursor.getInt(0)); |
| 123 } | 123 } |
| 124 } | 124 } |
| OLD | NEW |