| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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.browsing_data; | 5 package org.chromium.chrome.browser.browsing_data; |
| 6 | 6 |
| 7 import android.content.Intent; | 7 import android.content.Intent; |
| 8 import android.os.AsyncTask; | 8 import android.os.AsyncTask; |
| 9 import android.support.test.filters.MediumTest; | 9 import android.support.test.filters.MediumTest; |
| 10 | 10 |
| 11 import org.chromium.base.ThreadUtils; | 11 import org.chromium.base.ThreadUtils; |
| 12 import org.chromium.base.test.util.RetryOnFailure; | 12 import org.chromium.base.test.util.RetryOnFailure; |
| 13 import org.chromium.chrome.browser.ChromeActivity; | 13 import org.chromium.chrome.browser.ChromeActivity; |
| 14 import org.chromium.chrome.browser.ShortcutHelper; | 14 import org.chromium.chrome.browser.ShortcutHelper; |
| 15 import org.chromium.chrome.browser.preferences.PrefServiceBridge; | 15 import org.chromium.chrome.browser.preferences.privacy.BrowsingDataBridge; |
| 16 import org.chromium.chrome.browser.preferences.PrefServiceBridge.OnClearBrowsing
DataListener; | 16 import org.chromium.chrome.browser.preferences.privacy.BrowsingDataBridge.OnClea
rBrowsingDataListener; |
| 17 import org.chromium.chrome.browser.webapps.TestFetchStorageCallback; | 17 import org.chromium.chrome.browser.webapps.TestFetchStorageCallback; |
| 18 import org.chromium.chrome.browser.webapps.WebappRegistry; | 18 import org.chromium.chrome.browser.webapps.WebappRegistry; |
| 19 import org.chromium.chrome.test.ChromeActivityTestCaseBase; | 19 import org.chromium.chrome.test.ChromeActivityTestCaseBase; |
| 20 import org.chromium.content.browser.test.util.Criteria; | 20 import org.chromium.content.browser.test.util.Criteria; |
| 21 import org.chromium.content.browser.test.util.CriteriaHelper; | 21 import org.chromium.content.browser.test.util.CriteriaHelper; |
| 22 | 22 |
| 23 import java.util.Arrays; | 23 import java.util.Arrays; |
| 24 import java.util.HashMap; | 24 import java.util.HashMap; |
| 25 import java.util.HashSet; | 25 import java.util.HashSet; |
| 26 import java.util.Map; | 26 import java.util.Map; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 | 90 |
| 91 for (final Map.Entry<String, String> app : apps.entrySet()) { | 91 for (final Map.Entry<String, String> app : apps.entrySet()) { |
| 92 registerWebapp(app.getKey(), app.getValue()); | 92 registerWebapp(app.getKey(), app.getValue()); |
| 93 } | 93 } |
| 94 assertEquals(apps.keySet(), WebappRegistry.getRegisteredWebappIdsForTest
ing()); | 94 assertEquals(apps.keySet(), WebappRegistry.getRegisteredWebappIdsForTest
ing()); |
| 95 | 95 |
| 96 // Clear cookies and site data excluding the registrable domain "google.
com". | 96 // Clear cookies and site data excluding the registrable domain "google.
com". |
| 97 ThreadUtils.runOnUiThreadBlocking(new Runnable() { | 97 ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
| 98 @Override | 98 @Override |
| 99 public void run() { | 99 public void run() { |
| 100 PrefServiceBridge.getInstance().clearBrowsingDataExcludingDomain
s( | 100 BrowsingDataBridge.getInstance().clearBrowsingDataExcludingDomai
ns( |
| 101 new OnClearBrowsingDataListener() { | 101 new OnClearBrowsingDataListener() { |
| 102 @Override | 102 @Override |
| 103 public void onBrowsingDataCleared() { | 103 public void onBrowsingDataCleared() { |
| 104 mCallbackCalled = true; | 104 mCallbackCalled = true; |
| 105 } | 105 } |
| 106 }, | 106 }, |
| 107 new int[]{ BrowsingDataType.COOKIES }, | 107 new int[]{ BrowsingDataType.COOKIES }, |
| 108 TimePeriod.ALL_TIME, | 108 TimePeriod.ALL_TIME, |
| 109 new String[]{ "google.com" }, | 109 new String[]{ "google.com" }, |
| 110 new int[] { 1 }, | 110 new int[] { 1 }, |
| 111 new String[0], | 111 new String[0], |
| 112 new int[0]); | 112 new int[0]); |
| 113 } | 113 } |
| 114 }); | 114 }); |
| 115 CriteriaHelper.pollUiThread(new CallbackCriteria()); | 115 CriteriaHelper.pollUiThread(new CallbackCriteria()); |
| 116 | 116 |
| 117 // The last two webapps should have been unregistered. | 117 // The last two webapps should have been unregistered. |
| 118 assertEquals(new HashSet<String>(Arrays.asList("webapp1")), | 118 assertEquals(new HashSet<String>(Arrays.asList("webapp1")), |
| 119 WebappRegistry.getRegisteredWebappIdsForTesting()); | 119 WebappRegistry.getRegisteredWebappIdsForTesting()); |
| 120 | 120 |
| 121 // Clear cookies and site data with no url filter. | 121 // Clear cookies and site data with no url filter. |
| 122 ThreadUtils.runOnUiThreadBlocking(new Runnable() { | 122 ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
| 123 @Override | 123 @Override |
| 124 public void run() { | 124 public void run() { |
| 125 PrefServiceBridge.getInstance().clearBrowsingData( | 125 BrowsingDataBridge.getInstance().clearBrowsingData( |
| 126 new OnClearBrowsingDataListener() { | 126 new OnClearBrowsingDataListener() { |
| 127 @Override | 127 @Override |
| 128 public void onBrowsingDataCleared() { | 128 public void onBrowsingDataCleared() { |
| 129 mCallbackCalled = true; | 129 mCallbackCalled = true; |
| 130 } | 130 } |
| 131 }, | 131 }, |
| 132 new int[]{ BrowsingDataType.COOKIES }, | 132 new int[]{ BrowsingDataType.COOKIES }, |
| 133 TimePeriod.ALL_TIME); | 133 TimePeriod.ALL_TIME); |
| 134 } | 134 } |
| 135 }); | 135 }); |
| 136 CriteriaHelper.pollUiThread(new CallbackCriteria()); | 136 CriteriaHelper.pollUiThread(new CallbackCriteria()); |
| 137 | 137 |
| 138 // All webapps should have been unregistered. | 138 // All webapps should have been unregistered. |
| 139 assertTrue(WebappRegistry.getRegisteredWebappIdsForTesting().isEmpty()); | 139 assertTrue(WebappRegistry.getRegisteredWebappIdsForTesting().isEmpty()); |
| 140 } | 140 } |
| 141 } | 141 } |
| OLD | NEW |