| 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 "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 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 start_margin; |
| 355 int width; |
| 356 content::WebContents* preview_tab = instant()->GetPreviewContents(); |
| 357 EXPECT_TRUE(GetIntFromJS(preview_tab, "chrome.searchBox.startMargin", |
| 358 &start_margin)); |
| 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 show_home = profile_prefs->GetBoolean(prefs::kShowHomeButton); |
| 364 profile_prefs->SetBoolean(prefs::kShowHomeButton, !show_home); |
| 365 |
| 366 // Make sure the margin and width changed. |
| 367 int new_start_margin; |
| 368 int new_width; |
| 369 EXPECT_TRUE(GetIntFromJS(preview_tab, "chrome.searchBox.startMargin", |
| 370 &new_start_margin)); |
| 371 EXPECT_TRUE(GetIntFromJS(preview_tab, "chrome.searchBox.width", &new_width)); |
| 372 EXPECT_NE(start_margin, new_start_margin); |
| 373 EXPECT_NE(width, new_width); |
| 374 EXPECT_EQ(new_width - width, start_margin - new_start_margin); |
| 375 } |
| OLD | NEW |