Chromium Code Reviews| 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 "chrome/browser/instant/instant_commit_type.h" | 5 #include "chrome/browser/instant/instant_commit_type.h" |
| 6 #include "chrome/browser/instant/instant_ntp.h" | 6 #include "chrome/browser/instant/instant_ntp.h" |
| 7 #include "chrome/browser/instant/instant_overlay.h" | 7 #include "chrome/browser/instant/instant_overlay.h" |
| 8 #include "chrome/browser/instant/instant_service.h" | 8 #include "chrome/browser/instant/instant_service.h" |
| 9 #include "chrome/browser/instant/instant_service_factory.h" | 9 #include "chrome/browser/instant/instant_service_factory.h" |
| 10 #include "chrome/browser/instant/instant_test_utils.h" | 10 #include "chrome/browser/instant/instant_test_utils.h" |
| 11 #include "chrome/browser/prefs/pref_service.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 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 334 content::WebContents* active_tab = | 337 content::WebContents* active_tab = |
| 335 browser()->tab_strip_model()->GetActiveWebContents(); | 338 browser()->tab_strip_model()->GetActiveWebContents(); |
| 336 EXPECT_TRUE(instant_service->IsInstantProcess( | 339 EXPECT_TRUE(instant_service->IsInstantProcess( |
| 337 active_tab->GetRenderProcessHost()->GetID())); | 340 active_tab->GetRenderProcessHost()->GetID())); |
| 338 | 341 |
| 339 // Navigating elsewhere should not use the Instant render process. | 342 // Navigating elsewhere should not use the Instant render process. |
| 340 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIAboutURL)); | 343 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIAboutURL)); |
| 341 EXPECT_FALSE(instant_service->IsInstantProcess( | 344 EXPECT_FALSE(instant_service->IsInstantProcess( |
| 342 active_tab->GetRenderProcessHost()->GetID())); | 345 active_tab->GetRenderProcessHost()->GetID())); |
| 343 } | 346 } |
| 347 | |
| 348 // Check that toggling the state of the home button changes the start-edge | |
| 349 // margin and width. | |
| 350 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, HomeButtonAffectsMargin) { | |
| 351 ASSERT_NO_FATAL_FAILURE(SetupInstant()); | |
| 352 | |
| 353 // Get the current value of the start-edge margin and width. | |
| 354 int startMargin; | |
|
sreeram
2013/02/14 18:26:57
start_margin
melevin
2013/02/19 22:00:49
Oops, went into JavaScript mode...
| |
| 355 int width; | |
| 356 content::WebContents* preview_tab = instant()->GetPreviewContents(); | |
| 357 EXPECT_TRUE(GetIntFromJS(preview_tab, "chrome.searchBox.startMargin", | |
| 358 &startMargin)); | |
| 359 EXPECT_TRUE(GetIntFromJS(preview_tab, "chrome.searchBox.width", &width)); | |
| 360 | |
| 361 // Toggle the home button visibility pref. | |
| 362 PrefService* profile_prefs = browser()->profile()->GetPrefs(); | |
| 363 bool showHome = profile_prefs->GetBoolean(prefs::kShowHomeButton); | |
| 364 profile_prefs->SetBoolean(prefs::kShowHomeButton, !showHome); | |
| 365 | |
| 366 // Make sure the margin and width changed. | |
| 367 int newStartMargin; | |
| 368 int newWidth; | |
|
sreeram
2013/02/14 18:26:57
new_start_margin
new_width
melevin
2013/02/19 22:00:49
Done.
| |
| 369 EXPECT_TRUE(GetIntFromJS(preview_tab, "chrome.searchBox.startMargin", | |
| 370 &newStartMargin)); | |
| 371 EXPECT_TRUE(GetIntFromJS(preview_tab, "chrome.searchBox.width", &newWidth)); | |
| 372 EXPECT_NE(startMargin, newStartMargin); | |
| 373 EXPECT_NE(width, newWidth); | |
| 374 EXPECT_EQ(newWidth - width, startMargin - newStartMargin); | |
| 375 } | |
| OLD | NEW |