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

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: Added test 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 "chrome/browser/instant/instant_loader.h" 5 #include "chrome/browser/instant/instant_loader.h"
6 #include "chrome/browser/instant/instant_test_utils.h" 6 #include "chrome/browser/instant/instant_test_utils.h"
7 #include "chrome/browser/prefs/pref_service.h"
8 #include "chrome/browser/profiles/profile.h"
7 #include "chrome/browser/ui/search/search.h" 9 #include "chrome/browser/ui/search/search.h"
10 #include "chrome/common/pref_names.h"
8 #include "chrome/test/base/interactive_test_utils.h" 11 #include "chrome/test/base/interactive_test_utils.h"
9 #include "chrome/test/base/ui_test_utils.h" 12 #include "chrome/test/base/ui_test_utils.h"
10 13
11 class InstantExtendedTest : public InstantTestBase { 14 class InstantExtendedTest : public InstantTestBase {
12 protected: 15 protected:
13 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { 16 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
14 chrome::search::EnableInstantExtendedAPIForTesting(); 17 chrome::search::EnableInstantExtendedAPIForTesting();
15 ASSERT_TRUE(test_server()->Start()); 18 ASSERT_TRUE(test_server()->Start());
16 instant_url_ = test_server()->GetURL("files/instant_extended.html"); 19 instant_url_ = test_server()->GetURL("files/instant_extended.html");
17 } 20 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 content::WebContents* preview_tab = instant()->GetPreviewContents(); 76 content::WebContents* preview_tab = instant()->GetPreviewContents();
74 EXPECT_TRUE(preview_tab); 77 EXPECT_TRUE(preview_tab);
75 EXPECT_FALSE(instant()->IsPreviewingSearchResults()); 78 EXPECT_FALSE(instant()->IsPreviewingSearchResults());
76 EXPECT_TRUE(instant()->model()->mode().is_default()); 79 EXPECT_TRUE(instant()->model()->mode().is_default());
77 80
78 // Typing in the omnibox should show the overlay. 81 // Typing in the omnibox should show the overlay.
79 SetOmniboxTextAndWaitForInstantToShow("query"); 82 SetOmniboxTextAndWaitForInstantToShow("query");
80 EXPECT_TRUE(instant()->model()->mode().is_search_suggestions()); 83 EXPECT_TRUE(instant()->model()->mode().is_search_suggestions());
81 EXPECT_EQ(preview_tab, instant()->GetPreviewContents()); 84 EXPECT_EQ(preview_tab, instant()->GetPreviewContents());
82 } 85 }
86
87 // Check that toggling the state of the home button changes the start-edge
88 // margin and width.
89 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, HomeButtonAffectsMargin) {
90 ASSERT_NO_FATAL_FAILURE(SetupInstant());
91
92 // Get the current value of the start-edge margin and width.
93 int startMargin;
94 int width;
95 content::WebContents* preview_tab = instant()->GetPreviewContents();
96 EXPECT_TRUE(GetIntFromJS(preview_tab, "chrome.searchBox.startMargin",
97 &startMargin));
98 EXPECT_TRUE(GetIntFromJS(preview_tab, "chrome.searchBox.width", &width));
99
100 // Toggle the home button visibility pref.
101 PrefService* profile_prefs = browser()->profile()->GetPrefs();
102 bool showHome = profile_prefs->GetBoolean(prefs::kShowHomeButton);
103 profile_prefs->SetBoolean(prefs::kShowHomeButton, !showHome);
104
105 // Make sure the margin and width changed.
106 int newStartMargin;
107 int newWidth;
108 EXPECT_TRUE(GetIntFromJS(preview_tab, "chrome.searchBox.startMargin",
109 &newStartMargin));
110 EXPECT_TRUE(GetIntFromJS(preview_tab, "chrome.searchBox.width", &newWidth));
111 EXPECT_NE(startMargin, newStartMargin);
112 EXPECT_NE(width, newWidth);
samarth 2013/02/07 00:28:37 Is it always the case that the deltas between the
melevin 2013/02/07 21:21:23 Ah good point, that should be true.
113 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698