OLD | NEW |
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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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::PageTransitionFromInt( | 79 entry->SetTransitionType(ui::PageTransitionFromInt( |
80 content::PAGE_TRANSITION_GENERATED | | 80 ui::PAGE_TRANSITION_GENERATED | |
81 content::PAGE_TRANSITION_FROM_ADDRESS_BAR)); | 81 ui::PAGE_TRANSITION_FROM_ADDRESS_BAR)); |
82 } | 82 } |
83 entry->SetURL(GURL(url)); | 83 entry->SetURL(GURL(url)); |
84 details.entry = entry.get(); | 84 details.entry = entry.get(); |
85 | 85 |
86 // 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 |
87 // 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 |
88 // 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 |
89 // negative test cases (such as bad searches). | 89 // negative test cases (such as bad searches). |
90 if (expected_metric != GoogleSearchMetrics::AP_BOUNDARY) | 90 if (expected_metric != GoogleSearchMetrics::AP_BOUNDARY) |
91 ExpectMetricsLogged(expected_metric); | 91 ExpectMetricsLogged(expected_metric); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 TEST_F(GoogleSearchCounterTest, SearchAppStart) { | 140 TEST_F(GoogleSearchCounterTest, SearchAppStart) { |
141 // 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 |
142 // 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 |
143 // actual search because it has no query string parameter ("q"). | 143 // actual search because it has no query string parameter ("q"). |
144 TestGoogleSearch("http://www.google.com/webhp?source=search_app", | 144 TestGoogleSearch("http://www.google.com/webhp?source=search_app", |
145 false, GoogleSearchMetrics::AP_BOUNDARY); | 145 false, GoogleSearchMetrics::AP_BOUNDARY); |
146 } | 146 } |
147 | 147 |
148 // TODO(stevet): Add a regression test to protect against the particular | 148 // TODO(stevet): Add a regression test to protect against the particular |
149 // bad-flags handling case that asvitkine pointed out. | 149 // bad-flags handling case that asvitkine pointed out. |
OLD | NEW |