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

Unified Diff: components/omnibox/browser/physical_web_provider_unittest.cc

Issue 2689803002: Ensure nearby URL count metric is properly initialized (Closed)
Patch Set: remove BeginOmniboxSession, re-add histogram description Created 3 years, 10 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/omnibox/browser/physical_web_provider.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/omnibox/browser/physical_web_provider_unittest.cc
diff --git a/components/omnibox/browser/physical_web_provider_unittest.cc b/components/omnibox/browser/physical_web_provider_unittest.cc
index c7f537fb86fafbe70fd19e3cacc42b2ee926de16..063b555c716dec47b7e5da56e05c3a1a1dae0353 100644
--- a/components/omnibox/browser/physical_web_provider_unittest.cc
+++ b/components/omnibox/browser/physical_web_provider_unittest.cc
@@ -11,6 +11,7 @@
#include "base/metrics/field_trial.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
+#include "base/test/histogram_tester.h"
#include "components/metrics/proto/omnibox_event.pb.h"
#include "components/omnibox/browser/mock_autocomplete_provider_client.h"
#include "components/omnibox/browser/omnibox_field_trial.h"
@@ -428,3 +429,83 @@ TEST_F(PhysicalWebProviderTest, TestNoMatchesInIncognito) {
EXPECT_TRUE(provider_->matches().empty());
}
+
+TEST_F(PhysicalWebProviderTest, TestNearbyURLCountHistograms) {
+ FakePhysicalWebDataSource* data_source =
+ client_->GetFakePhysicalWebDataSource();
+ EXPECT_TRUE(data_source);
+
+ AutocompleteInput zero_suggest_input(CreateInputForNTP());
+ AutocompleteInput after_typing_input(
+ base::UTF8ToUTF16("Example"), 7, std::string(), GURL(),
+ metrics::OmniboxEventProto::INSTANT_NTP_WITH_OMNIBOX_AS_STARTING_FOCUS,
+ true, false, true, true, false, TestSchemeClassifier());
+
+ data_source->SetMetadataList(CreateMetadata(3));
+
+ {
+ // Simulate the user selecting a suggestion when the omnibox is empty
+ // (zero suggest case). Both histograms should record the same counts.
+ base::HistogramTester histogram_tester;
+ ProvidersInfo provider_info;
+
+ provider_->Start(zero_suggest_input, false);
+ provider_->AddProviderInfo(&provider_info);
+
+ histogram_tester.ExpectUniqueSample(
+ "Omnibox.SuggestionUsed.NearbyURLCount.AtMatchCreation", 3, 1);
+ histogram_tester.ExpectUniqueSample(
+ "Omnibox.SuggestionUsed.NearbyURLCount.AtFocus", 3, 1);
+ histogram_tester.ExpectUniqueSample(
+ "Omnibox.PhysicalWebProvider.SuggestionUsedWithoutOmniboxFocus", 0, 1);
+ }
+
+ {
+ // Simulate the user selecting a suggestion after typing a query (after
+ // typing case). Some additional URLs are discovered between focusing the
+ // omnibox and typing a query, so the counts should differ.
+ base::HistogramTester histogram_tester;
+ ProvidersInfo provider_info;
+
+ provider_->Start(zero_suggest_input, false);
+ data_source->SetMetadataList(CreateMetadata(6));
+ provider_->Start(after_typing_input, false);
+ provider_->AddProviderInfo(&provider_info);
+
+ histogram_tester.ExpectUniqueSample(
+ "Omnibox.SuggestionUsed.NearbyURLCount.AtMatchCreation", 6, 1);
+ histogram_tester.ExpectUniqueSample(
+ "Omnibox.SuggestionUsed.NearbyURLCount.AtFocus", 3, 1);
+ histogram_tester.ExpectUniqueSample(
+ "Omnibox.PhysicalWebProvider.SuggestionUsedWithoutOmniboxFocus", 0, 1);
+ }
+}
+
+TEST_F(PhysicalWebProviderTest, TestNearbyURLCountAfterTypingWithoutFocus) {
+ FakePhysicalWebDataSource* data_source =
+ client_->GetFakePhysicalWebDataSource();
+ EXPECT_TRUE(data_source);
+
+ AutocompleteInput after_typing_input(
+ base::UTF8ToUTF16("Example"), 7, std::string(), GURL(),
+ metrics::OmniboxEventProto::INSTANT_NTP_WITH_OMNIBOX_AS_STARTING_FOCUS,
+ true, false, true, true, false, TestSchemeClassifier());
+
+ data_source->SetMetadataList(CreateMetadata(3));
+
+ {
+ // Simulate selecting a suggestion without focusing the omnibox first.
+ base::HistogramTester histogram_tester;
+ ProvidersInfo provider_info;
+
+ provider_->Start(after_typing_input, false);
+ provider_->AddProviderInfo(&provider_info);
+
+ histogram_tester.ExpectUniqueSample(
+ "Omnibox.SuggestionUsed.NearbyURLCount.AtMatchCreation", 3, 1);
+ histogram_tester.ExpectTotalCount(
+ "Omnibox.SuggestionUsed.NearbyURLCount.AtFocus", 0);
+ histogram_tester.ExpectUniqueSample(
+ "Omnibox.PhysicalWebProvider.SuggestionUsedWithoutOmniboxFocus", 1, 1);
+ }
+}
« no previous file with comments | « components/omnibox/browser/physical_web_provider.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698