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

Side by Side Diff: chrome/browser/instant/instant_extended_browsertest.cc

Issue 12047107: Change the SearchBox API from using the start/end margins of the location bar to using the start ma… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync Created 7 years, 10 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 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 "base/prefs/pref_service.h"
5 #include "chrome/browser/instant/instant_commit_type.h" 6 #include "chrome/browser/instant/instant_commit_type.h"
6 #include "chrome/browser/instant/instant_ntp.h" 7 #include "chrome/browser/instant/instant_ntp.h"
7 #include "chrome/browser/instant/instant_overlay.h" 8 #include "chrome/browser/instant/instant_overlay.h"
8 #include "chrome/browser/instant/instant_service.h" 9 #include "chrome/browser/instant/instant_service.h"
9 #include "chrome/browser/instant/instant_service_factory.h" 10 #include "chrome/browser/instant/instant_service_factory.h"
10 #include "chrome/browser/instant/instant_test_utils.h" 11 #include "chrome/browser/instant/instant_test_utils.h"
12 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/ui/search/search.h" 13 #include "chrome/browser/ui/search/search.h"
12 #include "chrome/browser/ui/tabs/tab_strip_model.h" 14 #include "chrome/browser/ui/tabs/tab_strip_model.h"
13 #include "chrome/common/chrome_notification_types.h" 15 #include "chrome/common/chrome_notification_types.h"
16 #include "chrome/common/pref_names.h"
14 #include "chrome/common/url_constants.h" 17 #include "chrome/common/url_constants.h"
15 #include "chrome/test/base/interactive_test_utils.h" 18 #include "chrome/test/base/interactive_test_utils.h"
16 #include "chrome/test/base/ui_test_utils.h" 19 #include "chrome/test/base/ui_test_utils.h"
17 #include "content/public/browser/notification_service.h" 20 #include "content/public/browser/notification_service.h"
18 #include "content/public/browser/render_process_host.h" 21 #include "content/public/browser/render_process_host.h"
19 #include "content/public/browser/web_contents.h" 22 #include "content/public/browser/web_contents.h"
20 23
21 class InstantExtendedTest : public InstantTestBase { 24 class InstantExtendedTest : public InstantTestBase {
22 protected: 25 protected:
23 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { 26 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 content::WebContents* active_tab = 406 content::WebContents* active_tab =
404 browser()->tab_strip_model()->GetActiveWebContents(); 407 browser()->tab_strip_model()->GetActiveWebContents();
405 EXPECT_TRUE(instant_service->IsInstantProcess( 408 EXPECT_TRUE(instant_service->IsInstantProcess(
406 active_tab->GetRenderProcessHost()->GetID())); 409 active_tab->GetRenderProcessHost()->GetID()));
407 410
408 // Navigating elsewhere should not use the Instant render process. 411 // Navigating elsewhere should not use the Instant render process.
409 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIAboutURL)); 412 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIAboutURL));
410 EXPECT_FALSE(instant_service->IsInstantProcess( 413 EXPECT_FALSE(instant_service->IsInstantProcess(
411 active_tab->GetRenderProcessHost()->GetID())); 414 active_tab->GetRenderProcessHost()->GetID()));
412 } 415 }
416
417 // Check that toggling the state of the home button changes the start-edge
418 // margin and width.
419 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, HomeButtonAffectsMargin) {
420 ASSERT_NO_FATAL_FAILURE(SetupInstant());
421
422 // Get the current value of the start-edge margin and width.
423 int start_margin;
424 int width;
425 content::WebContents* preview_tab = instant()->GetPreviewContents();
426 EXPECT_TRUE(GetIntFromJS(preview_tab, "chrome.searchBox.startMargin",
427 &start_margin));
428 EXPECT_TRUE(GetIntFromJS(preview_tab, "chrome.searchBox.width", &width));
429
430 // Toggle the home button visibility pref.
431 PrefService* profile_prefs = browser()->profile()->GetPrefs();
432 bool show_home = profile_prefs->GetBoolean(prefs::kShowHomeButton);
433 profile_prefs->SetBoolean(prefs::kShowHomeButton, !show_home);
434
435 // Make sure the margin and width changed.
436 int new_start_margin;
437 int new_width;
438 EXPECT_TRUE(GetIntFromJS(preview_tab, "chrome.searchBox.startMargin",
439 &new_start_margin));
440 EXPECT_TRUE(GetIntFromJS(preview_tab, "chrome.searchBox.width", &new_width));
441 EXPECT_NE(start_margin, new_start_margin);
442 EXPECT_NE(width, new_width);
443 EXPECT_EQ(new_width - width, start_margin - new_start_margin);
444 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698