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

Side by Side Diff: chrome/browser/google/google_search_counter_unittest.cc

Issue 342053002: Add UMA metrics for Android Chrome Google Search. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "chrome/browser/google/google_search_counter.h" 5 #include "chrome/browser/google/google_search_counter.h"
6 #include "components/google/core/browser/google_search_metrics.h" 6 #include "components/google/core/browser/google_search_metrics.h"
7 #include "content/public/browser/navigation_controller.h" 7 #include "content/public/browser/navigation_controller.h"
8 #include "content/public/browser/navigation_details.h" 8 #include "content/public/browser/navigation_details.h"
9 #include "content/public/browser/navigation_entry.h" 9 #include "content/public/browser/navigation_entry.h"
10 #include "content/public/browser/notification_service.h" 10 #include "content/public/browser/notification_service.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 mock_search_metrics_ = NULL; 68 mock_search_metrics_ = NULL;
69 } 69 }
70 70
71 void GoogleSearchCounterTest::TestGoogleSearch( 71 void GoogleSearchCounterTest::TestGoogleSearch(
72 const std::string& url, 72 const std::string& url,
73 bool is_omnibox, 73 bool is_omnibox,
74 GoogleSearchMetrics::AccessPoint expected_metric) { 74 GoogleSearchMetrics::AccessPoint expected_metric) {
75 content::LoadCommittedDetails details; 75 content::LoadCommittedDetails details;
76 scoped_ptr<content::NavigationEntry> entry( 76 scoped_ptr<content::NavigationEntry> entry(
77 content::NavigationEntry::Create()); 77 content::NavigationEntry::Create());
78 if (is_omnibox) 78 if (is_omnibox) {
79 entry->SetTransitionType(content::PAGE_TRANSITION_GENERATED); 79 entry->SetTransitionType(content::PageTransitionFromInt(
80 content::PAGE_TRANSITION_GENERATED |
81 content::PAGE_TRANSITION_FROM_ADDRESS_BAR));
82 }
80 entry->SetURL(GURL(url)); 83 entry->SetURL(GURL(url));
81 details.entry = entry.get(); 84 details.entry = entry.get();
82 85
83 // Since the internal mocked metrics object is strict, if |expect_metrics| is 86 // Since the internal mocked metrics object is strict, if |expect_metrics| is
84 // false, the absence of this call to ExpectMetricsLogged will be noticed and 87 // false, the absence of this call to ExpectMetricsLogged will be noticed and
85 // cause the test to complain, as expected. We use this behaviour to test 88 // cause the test to complain, as expected. We use this behaviour to test
86 // negative test cases (such as bad searches). 89 // negative test cases (such as bad searches).
87 if (expected_metric != GoogleSearchMetrics::AP_BOUNDARY) 90 if (expected_metric != GoogleSearchMetrics::AP_BOUNDARY)
88 ExpectMetricsLogged(expected_metric); 91 ExpectMetricsLogged(expected_metric);
89 92
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 TEST_F(GoogleSearchCounterTest, SearchAppStart) { 140 TEST_F(GoogleSearchCounterTest, SearchAppStart) {
138 // Starting the search app takes you to this URL, but it should not be 141 // Starting the search app takes you to this URL, but it should not be
139 // considered an actual search event. Note that this URL is not considered an 142 // considered an actual search event. Note that this URL is not considered an
140 // actual search because it has no query string parameter ("q"). 143 // actual search because it has no query string parameter ("q").
141 TestGoogleSearch("http://www.google.com/webhp?source=search_app", 144 TestGoogleSearch("http://www.google.com/webhp?source=search_app",
142 false, GoogleSearchMetrics::AP_BOUNDARY); 145 false, GoogleSearchMetrics::AP_BOUNDARY);
143 } 146 }
144 147
145 // TODO(stevet): Add a regression test to protect against the particular 148 // TODO(stevet): Add a regression test to protect against the particular
146 // bad-flags handling case that asvitkine pointed out. 149 // bad-flags handling case that asvitkine pointed out.
OLDNEW
« no previous file with comments | « chrome/browser/google/google_search_counter_android.cc ('k') | chrome/browser/prerender/prerender_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698