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

Side by Side Diff: chrome/browser/search/search_unittest.cc

Issue 19872007: Use process per site instance for "Instant". (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments Created 7 years, 5 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/metrics/field_trial.h" 6 #include "base/metrics/field_trial.h"
7 #include "base/metrics/histogram_base.h" 7 #include "base/metrics/histogram_base.h"
8 #include "base/metrics/histogram_samples.h" 8 #include "base/metrics/histogram_samples.h"
9 #include "base/metrics/statistics_recorder.h" 9 #include "base/metrics/statistics_recorder.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 }; 283 };
284 284
285 for (size_t i = 0; i < arraysize(kTestCases); ++i) { 285 for (size_t i = 0; i < arraysize(kTestCases); ++i) {
286 const SearchTestCase& test = kTestCases[i]; 286 const SearchTestCase& test = kTestCases[i];
287 EXPECT_EQ(test.expected_result, 287 EXPECT_EQ(test.expected_result,
288 ShouldAssignURLToInstantRenderer(GURL(test.url), profile())) 288 ShouldAssignURLToInstantRenderer(GURL(test.url), profile()))
289 << test.url << " " << test.comment; 289 << test.url << " " << test.comment;
290 } 290 }
291 } 291 }
292 292
293 TEST_F(SearchTest, ShouldUseProcessPerSiteForInstantURL) {
294 EnableInstantExtendedAPIForTesting();
295
296 const SearchTestCase kTestCases[] = {
297 {"chrome-search://local-ntp", true, "Local NTP"},
298 {"chrome-search://online-ntp", true, "Online NTP"},
299 {"invalid-scheme://local-ntp", false, "Invalid Local NTP URL"},
300 {"invalid-scheme://online-ntp", false, "Invalid Online NTP URL"},
301 {"chrome-search://foo.com", false, "Search result page"},
302 {"https://foo.com/instant?strk", false, ""},
303 {"https://foo.com/instant#strk", false, ""},
304 {"https://foo.com/instant?strk=0", false, ""},
305 {"https://foo.com/url?strk", false, ""},
306 {"https://foo.com/alt?strk", false, ""},
307 {"http://foo.com/instant", false, "Non-HTTPS"},
308 {"http://foo.com/instant?strk", false, "Non-HTTPS"},
309 {"http://foo.com/instant?strk=1", false, "Non-HTTPS"},
310 {"https://foo.com/instant", false, "No search terms replacement"},
311 {"https://foo.com/?strk", false, "Non-exact path"},
312 };
313
314 for (size_t i = 0; i < arraysize(kTestCases); ++i) {
315 const SearchTestCase& test = kTestCases[i];
316 EXPECT_EQ(test.expected_result,
317 ShouldUseProcessPerSiteForInstantURL(GURL(test.url), profile()))
318 << test.url << " " << test.comment;
319 }
320 }
321
293 struct PrivilegedURLTestCase { 322 struct PrivilegedURLTestCase {
294 bool add_as_alternate_url; 323 bool add_as_alternate_url;
295 const char* input_url; 324 const char* input_url;
296 const char* privileged_url; 325 const char* privileged_url;
297 bool different_site_instance; 326 bool different_site_instance;
298 const char* comment; 327 const char* comment;
299 }; 328 };
300 329
301 TEST_F(SearchTest, GetPrivilegedURLForInstant) { 330 TEST_F(SearchTest, GetPrivilegedURLForInstant) {
302 EnableInstantExtendedAPIForTesting(); 331 EnableInstantExtendedAPIForTesting();
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 // If we specify extra search query params, they should be inserted into the 577 // If we specify extra search query params, they should be inserted into the
549 // query portion of the instant URL. 578 // query portion of the instant URL.
550 CommandLine::ForCurrentProcess()->AppendSwitchASCII( 579 CommandLine::ForCurrentProcess()->AppendSwitchASCII(
551 switches::kExtraSearchQueryParams, "a=b"); 580 switches::kExtraSearchQueryParams, "a=b");
552 instant_url = GetInstantURL(profile(), kDisableStartMargin); 581 instant_url = GetInstantURL(profile(), kDisableStartMargin);
553 ASSERT_TRUE(instant_url.is_valid()); 582 ASSERT_TRUE(instant_url.is_valid());
554 EXPECT_EQ("http://www.bar.com/webhp?a=b&strk", instant_url.spec()); 583 EXPECT_EQ("http://www.bar.com/webhp?a=b&strk", instant_url.spec());
555 } 584 }
556 585
557 } // namespace chrome 586 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/search/search.cc ('k') | chrome/browser/ui/search/instant_extended_interactive_uitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698