OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "base/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
6 #include "base/message_loop/message_loop.h" | 6 #include "base/message_loop/message_loop.h" |
7 #include "chrome/browser/google/google_search_counter.h" | 7 #include "chrome/browser/google/google_search_counter.h" |
8 #include "chrome/browser/google/google_search_counter_android.h" | 8 #include "chrome/browser/google/google_search_counter_android.h" |
9 #include "chrome/browser/prerender/prerender_manager.h" | 9 #include "chrome/browser/prerender/prerender_manager.h" |
10 #include "chrome/test/base/testing_profile.h" | 10 #include "chrome/test/base/testing_profile.h" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 | 88 |
89 void GoogleSearchCounterAndroidTest::TestGoogleSearch( | 89 void GoogleSearchCounterAndroidTest::TestGoogleSearch( |
90 const std::string& url, | 90 const std::string& url, |
91 bool is_omnibox, | 91 bool is_omnibox, |
92 GoogleSearchMetrics::AccessPoint expected_metric, | 92 GoogleSearchMetrics::AccessPoint expected_metric, |
93 bool expected_prerender_enabled) { | 93 bool expected_prerender_enabled) { |
94 content::LoadCommittedDetails details; | 94 content::LoadCommittedDetails details; |
95 scoped_ptr<content::NavigationEntry> entry( | 95 scoped_ptr<content::NavigationEntry> entry( |
96 content::NavigationEntry::Create()); | 96 content::NavigationEntry::Create()); |
97 if (is_omnibox) { | 97 if (is_omnibox) { |
98 entry->SetTransitionType(content::PageTransitionFromInt( | 98 entry->SetTransitionType(ui::PageTransitionFromInt( |
99 content::PAGE_TRANSITION_GENERATED | | 99 ui::PAGE_TRANSITION_GENERATED | |
100 content::PAGE_TRANSITION_FROM_ADDRESS_BAR)); | 100 ui::PAGE_TRANSITION_FROM_ADDRESS_BAR)); |
101 } | 101 } |
102 entry->SetURL(GURL(url)); | 102 entry->SetURL(GURL(url)); |
103 details.entry = entry.get(); | 103 details.entry = entry.get(); |
104 | 104 |
105 // Since the internal mocked metrics object is strict, if |expect_metrics| is | 105 // Since the internal mocked metrics object is strict, if |expect_metrics| is |
106 // false, the absence of this call to ExpectMetricsLogged will be noticed and | 106 // false, the absence of this call to ExpectMetricsLogged will be noticed and |
107 // cause the test to complain, as expected. We use this behaviour to test | 107 // cause the test to complain, as expected. We use this behaviour to test |
108 // negative test cases (such as bad searches). | 108 // negative test cases (such as bad searches). |
109 if (expected_metric != GoogleSearchMetrics::AP_BOUNDARY) | 109 if (expected_metric != GoogleSearchMetrics::AP_BOUNDARY) |
110 ExpectMetricsLogged(expected_metric, expected_prerender_enabled); | 110 ExpectMetricsLogged(expected_metric, expected_prerender_enabled); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 TestGoogleSearch("http://www.google.com/webhp?source=search_app", | 165 TestGoogleSearch("http://www.google.com/webhp?source=search_app", |
166 false, GoogleSearchMetrics::AP_BOUNDARY, true); | 166 false, GoogleSearchMetrics::AP_BOUNDARY, true); |
167 } | 167 } |
168 | 168 |
169 TEST_F(GoogleSearchCounterAndroidTest, GoodOmniboxSearch_PrerenderDisabled) { | 169 TEST_F(GoogleSearchCounterAndroidTest, GoodOmniboxSearch_PrerenderDisabled) { |
170 prerender::PrerenderManager::SetMode( | 170 prerender::PrerenderManager::SetMode( |
171 prerender::PrerenderManager::PRERENDER_MODE_DISABLED); | 171 prerender::PrerenderManager::PRERENDER_MODE_DISABLED); |
172 TestGoogleSearch("http://www.google.com/search?q=something", true, | 172 TestGoogleSearch("http://www.google.com/search?q=something", true, |
173 GoogleSearchMetrics::AP_OMNIBOX, false); | 173 GoogleSearchMetrics::AP_OMNIBOX, false); |
174 } | 174 } |
OLD | NEW |