| 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 <sstream> | 5 #include <sstream> |
| 6 | 6 |
| 7 #include "base/prefs/pref_service.h" |
| 7 #include "chrome/browser/favicon/favicon_tab_helper.h" | 8 #include "chrome/browser/favicon/favicon_tab_helper.h" |
| 8 #include "chrome/browser/instant/instant_commit_type.h" | 9 #include "chrome/browser/instant/instant_commit_type.h" |
| 9 #include "chrome/browser/instant/instant_ntp.h" | 10 #include "chrome/browser/instant/instant_ntp.h" |
| 10 #include "chrome/browser/instant/instant_overlay.h" | 11 #include "chrome/browser/instant/instant_overlay.h" |
| 11 #include "chrome/browser/instant/instant_service.h" | 12 #include "chrome/browser/instant/instant_service.h" |
| 12 #include "chrome/browser/instant/instant_service_factory.h" | 13 #include "chrome/browser/instant/instant_service_factory.h" |
| 13 #include "chrome/browser/instant/instant_test_utils.h" | 14 #include "chrome/browser/instant/instant_test_utils.h" |
| 15 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/browser/ui/search/search.h" | 16 #include "chrome/browser/ui/search/search.h" |
| 15 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 17 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 16 #include "chrome/common/chrome_notification_types.h" | 18 #include "chrome/common/chrome_notification_types.h" |
| 19 #include "chrome/common/pref_names.h" |
| 17 #include "chrome/common/url_constants.h" | 20 #include "chrome/common/url_constants.h" |
| 18 #include "chrome/test/base/interactive_test_utils.h" | 21 #include "chrome/test/base/interactive_test_utils.h" |
| 19 #include "chrome/test/base/ui_test_utils.h" | 22 #include "chrome/test/base/ui_test_utils.h" |
| 20 #include "content/public/browser/notification_service.h" | 23 #include "content/public/browser/notification_service.h" |
| 21 #include "content/public/browser/render_process_host.h" | 24 #include "content/public/browser/render_process_host.h" |
| 22 #include "content/public/browser/site_instance.h" | 25 #include "content/public/browser/site_instance.h" |
| 23 #include "content/public/browser/web_contents.h" | 26 #include "content/public/browser/web_contents.h" |
| 24 | 27 |
| 25 class InstantExtendedTest : public InstantTestBase { | 28 class InstantExtendedTest : public InstantTestBase { |
| 26 public: | 29 public: |
| (...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 687 stream << "apiHandle.undoAllMostVisitedDeletions()"; | 690 stream << "apiHandle.undoAllMostVisitedDeletions()"; |
| 688 EXPECT_TRUE(ExecuteScript(stream.str())); | 691 EXPECT_TRUE(ExecuteScript(stream.str())); |
| 689 observer.Wait(); | 692 observer.Wait(); |
| 690 | 693 |
| 691 // Update Most Visited state. | 694 // Update Most Visited state. |
| 692 EXPECT_TRUE(UpdateSearchState(preview_tab)); | 695 EXPECT_TRUE(UpdateSearchState(preview_tab)); |
| 693 | 696 |
| 694 // Make sure we have the same number of items as before. | 697 // Make sure we have the same number of items as before. |
| 695 EXPECT_EQ(most_visited_items_count_, old_most_visited_items_count); | 698 EXPECT_EQ(most_visited_items_count_, old_most_visited_items_count); |
| 696 } | 699 } |
| 700 |
| 701 // Check that toggling the state of the home button changes the start-edge |
| 702 // margin and width. |
| 703 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, HomeButtonAffectsMargin) { |
| 704 ASSERT_NO_FATAL_FAILURE(SetupInstant()); |
| 705 |
| 706 // Get the current value of the start-edge margin and width. |
| 707 int start_margin; |
| 708 int width; |
| 709 content::WebContents* preview_tab = instant()->GetPreviewContents(); |
| 710 EXPECT_TRUE(GetIntFromJS(preview_tab, "chrome.searchBox.startMargin", |
| 711 &start_margin)); |
| 712 EXPECT_TRUE(GetIntFromJS(preview_tab, "chrome.searchBox.width", &width)); |
| 713 |
| 714 // Toggle the home button visibility pref. |
| 715 PrefService* profile_prefs = browser()->profile()->GetPrefs(); |
| 716 bool show_home = profile_prefs->GetBoolean(prefs::kShowHomeButton); |
| 717 profile_prefs->SetBoolean(prefs::kShowHomeButton, !show_home); |
| 718 |
| 719 // Make sure the margin and width changed. |
| 720 int new_start_margin; |
| 721 int new_width; |
| 722 EXPECT_TRUE(GetIntFromJS(preview_tab, "chrome.searchBox.startMargin", |
| 723 &new_start_margin)); |
| 724 EXPECT_TRUE(GetIntFromJS(preview_tab, "chrome.searchBox.width", &new_width)); |
| 725 EXPECT_NE(start_margin, new_start_margin); |
| 726 EXPECT_NE(width, new_width); |
| 727 EXPECT_EQ(new_width - width, start_margin - new_start_margin); |
| 728 } |
| OLD | NEW |