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

Unified Diff: chrome/browser/android/data_usage/external_data_use_observer_unittest.cc

Issue 1774973004: Fetching the matching rules when control app is installed (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 | « chrome/browser/android/data_usage/data_use_tab_model.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/android/data_usage/external_data_use_observer_unittest.cc
diff --git a/chrome/browser/android/data_usage/external_data_use_observer_unittest.cc b/chrome/browser/android/data_usage/external_data_use_observer_unittest.cc
index dbe89efb10f73d90dffb3ac17553c1ed7f7ddbc2..5768b3f5ab0331aec50414919c33b0b3a3181fb9 100644
--- a/chrome/browser/android/data_usage/external_data_use_observer_unittest.cc
+++ b/chrome/browser/android/data_usage/external_data_use_observer_unittest.cc
@@ -383,10 +383,11 @@ TEST_F(ExternalDataUseObserverTest, PeriodicFetchMatchingRules) {
}
// Tests the matching rule fetch behavior when the external control app is
-// installed and not installed. If control app is installed and no valid rules
-// are found, matching rules are fetched on every navigation. Rules are not
-// fetched if control app is not installed or if more than zero valid rules
-// have been fetched.
+// installed and not installed. Matching rules should be fetched when control
+// app gets installed. If control app is installed and no valid rules are found,
+// matching rules are fetched on every navigation. Rules are not fetched if
+// control app is not installed or if more than zero valid rules have been
+// fetched.
TEST_F(ExternalDataUseObserverTest, MatchingRuleFetchOnControlAppInstall) {
// Matching rules not fetched on navigation if control app is not installed.
external_data_use_observer()->last_matching_rules_fetch_time_ =
@@ -399,10 +400,17 @@ TEST_F(ExternalDataUseObserverTest, MatchingRuleFetchOnControlAppInstall) {
EXPECT_TRUE(
external_data_use_observer()->last_matching_rules_fetch_time_.is_null());
- // Matching rules fetched on every navigation if control app is installed and
- // zero rules are available.
+ // Matching rules are fetched when control app is installed.
external_data_use_observer()
->data_use_tab_model_->OnControlAppInstallStateChange(true);
+ base::RunLoop().RunUntilIdle();
+ EXPECT_FALSE(
+ external_data_use_observer()->last_matching_rules_fetch_time_.is_null());
+
+ // Matching rules fetched on every navigation if control app is installed and
+ // zero rules are available.
+ external_data_use_observer()->last_matching_rules_fetch_time_ =
+ base::TimeTicks();
external_data_use_observer()->data_use_tab_model_->OnNavigationEvent(
kDefaultTabId, DataUseTabModel::TRANSITION_LINK, GURL(kDefaultURL),
std::string());
@@ -587,15 +595,16 @@ TEST_F(ExternalDataUseObserverTest, DataUseReportTimedOut) {
// Create another ExternalDataUseObserver object.
ReplaceExternalDataUseObserver(variation_params);
- // Trigger the control app install.
+ // Trigger the control app install, and matching rules will be fetched.
external_data_use_observer()
->GetDataUseTabModel()
->OnControlAppInstallStateChange(true);
+ base::RunLoop().RunUntilIdle();
histogram_tester.ExpectTotalCount(kUMAMatchingRuleFirstFetchDurationHistogram,
- 0);
+ 1);
- // Verify that matching rules are fetched on the first navigation after the
- // control app is installed.
+ // Verify that matching rules are fetched on every navigation after the
+ // control app is installed, since there are no valid rules yet.
external_data_use_observer()->GetDataUseTabModel()->OnNavigationEvent(
kDefaultTabId, DataUseTabModel::TRANSITION_OMNIBOX_SEARCH,
GURL(kDefaultURL), std::string());
« no previous file with comments | « chrome/browser/android/data_usage/data_use_tab_model.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698