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

Unified Diff: chrome/browser/search_engines/template_url_service_unittest.cc

Issue 2810233005: Fixed minor bug with Search.DefaultSearchChangeOrigin histogram (Closed)
Patch Set: Created 3 years, 8 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 | « no previous file | components/search_engines/template_url_service.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/search_engines/template_url_service_unittest.cc
diff --git a/chrome/browser/search_engines/template_url_service_unittest.cc b/chrome/browser/search_engines/template_url_service_unittest.cc
index c3b8de661f0c6b8c009edbf0d440e4c34cd821b0..9ec307fc0510367687fe267ac12591fe665dadae 100644
--- a/chrome/browser/search_engines/template_url_service_unittest.cc
+++ b/chrome/browser/search_engines/template_url_service_unittest.cc
@@ -20,6 +20,7 @@
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/cancelable_task_tracker.h"
+#include "base/test/histogram_tester.h"
#include "base/test/simple_test_clock.h"
#include "base/threading/thread.h"
#include "base/time/time.h"
@@ -1944,3 +1945,22 @@ TEST_F(TemplateURLServiceTest, LastModifiedTimeUpdate) {
EXPECT_NE(original_last_modified, reloaded_last_modified);
EXPECT_EQ(update_last_modified, reloaded_last_modified);
}
+
+// Tests checks that Search.DefaultSearchChangeOrigin histogram is correctly
+// emitted when TemplateURLService is not yet loaded.
Peter Kasting 2017/04/14 08:02:00 Another way of testing would be to verify that Tem
+TEST_F(TemplateURLServiceTest, ChangeDefaultEngineBeforeLoad) {
+ TemplateURL* search_engine1 = model()->Add(
+ base::MakeUnique<TemplateURL>(*GenerateDummyTemplateURLData("keyword1")));
+ DCHECK(search_engine1);
+ TemplateURL* search_engine2 = model()->Add(
+ base::MakeUnique<TemplateURL>(*GenerateDummyTemplateURLData("keyword2")));
+ DCHECK(search_engine2);
+
+ base::HistogramTester histogram_tester;
+ model()->SetUserSelectedDefaultSearchProvider(search_engine1);
+ histogram_tester.ExpectTotalCount("Search.DefaultSearchChangeOrigin", 1);
+ model()->SetUserSelectedDefaultSearchProvider(search_engine1);
+ histogram_tester.ExpectTotalCount("Search.DefaultSearchChangeOrigin", 1);
+ model()->SetUserSelectedDefaultSearchProvider(search_engine2);
+ histogram_tester.ExpectTotalCount("Search.DefaultSearchChangeOrigin", 2);
+}
« no previous file with comments | « no previous file | components/search_engines/template_url_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698