OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <string> | 5 #include <string> |
| 6 #include <tuple> |
6 #include <vector> | 7 #include <vector> |
7 | 8 |
8 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
9 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
10 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
11 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
12 #include "chrome/browser/search/instant_service.h" | 13 #include "chrome/browser/search/instant_service.h" |
13 #include "chrome/browser/search/instant_service_observer.h" | 14 #include "chrome/browser/search/instant_service_observer.h" |
14 #include "chrome/browser/search/instant_unittest_base.h" | 15 #include "chrome/browser/search/instant_unittest_base.h" |
15 #include "chrome/browser/search/search.h" | 16 #include "chrome/browser/search/search.h" |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 rph->sink().ClearMessages(); | 106 rph->sink().ClearMessages(); |
106 instant_service_->Observe( | 107 instant_service_->Observe( |
107 content::NOTIFICATION_RENDERER_PROCESS_CREATED, | 108 content::NOTIFICATION_RENDERER_PROCESS_CREATED, |
108 content::Source<content::MockRenderProcessHost>(rph.get()), | 109 content::Source<content::MockRenderProcessHost>(rph.get()), |
109 content::NotificationService::NoDetails()); | 110 content::NotificationService::NoDetails()); |
110 EXPECT_EQ(1U, rph->sink().message_count()); | 111 EXPECT_EQ(1U, rph->sink().message_count()); |
111 const IPC::Message* msg = rph->sink().GetMessageAt(0); | 112 const IPC::Message* msg = rph->sink().GetMessageAt(0); |
112 ASSERT_TRUE(msg); | 113 ASSERT_TRUE(msg); |
113 ChromeViewMsg_SetSearchURLs::Param params; | 114 ChromeViewMsg_SetSearchURLs::Param params; |
114 ChromeViewMsg_SetSearchURLs::Read(msg, ¶ms); | 115 ChromeViewMsg_SetSearchURLs::Read(msg, ¶ms); |
115 std::vector<GURL> search_urls = base::get<0>(params); | 116 std::vector<GURL> search_urls = std::get<0>(params); |
116 GURL new_tab_page_url = base::get<1>(params); | 117 GURL new_tab_page_url = std::get<1>(params); |
117 EXPECT_EQ(2U, search_urls.size()); | 118 EXPECT_EQ(2U, search_urls.size()); |
118 EXPECT_EQ("https://www.google.com/alt#quux=", search_urls[0].spec()); | 119 EXPECT_EQ("https://www.google.com/alt#quux=", search_urls[0].spec()); |
119 EXPECT_EQ("https://www.google.com/url?bar=", search_urls[1].spec()); | 120 EXPECT_EQ("https://www.google.com/url?bar=", search_urls[1].spec()); |
120 EXPECT_EQ("https://www.google.com/newtab", new_tab_page_url.spec()); | 121 EXPECT_EQ("https://www.google.com/newtab", new_tab_page_url.spec()); |
121 } | 122 } |
122 | 123 |
123 TEST_F(InstantServiceTest, InstantSearchEnabled) { | 124 TEST_F(InstantServiceTest, InstantSearchEnabled) { |
124 EXPECT_NE(static_cast<InstantSearchPrerenderer*>(NULL), | 125 EXPECT_NE(static_cast<InstantSearchPrerenderer*>(NULL), |
125 GetInstantSearchPrerenderer()); | 126 GetInstantSearchPrerenderer()); |
126 } | 127 } |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 InstantMostVisitedItem chromium_item; | 219 InstantMostVisitedItem chromium_item; |
219 chromium_item.url = GURL("https://chromium.org"); | 220 chromium_item.url = GURL("https://chromium.org"); |
220 suggestions_items().push_back(chromium_item); | 221 suggestions_items().push_back(chromium_item); |
221 EXPECT_TRUE(instant_service_->IsValidURLForNavigation(chromium_item.url)); | 222 EXPECT_TRUE(instant_service_->IsValidURLForNavigation(chromium_item.url)); |
222 | 223 |
223 // http://chromium.org is web safe, but not in |suggestions_items_| or | 224 // http://chromium.org is web safe, but not in |suggestions_items_| or |
224 // |most_visited_items_|, so it should be denied. | 225 // |most_visited_items_|, so it should be denied. |
225 EXPECT_FALSE( | 226 EXPECT_FALSE( |
226 instant_service_->IsValidURLForNavigation(GURL("http://chromium.org"))); | 227 instant_service_->IsValidURLForNavigation(GURL("http://chromium.org"))); |
227 } | 228 } |
OLD | NEW |