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

Side by Side Diff: chrome/browser/dom_ui/new_tab_ui_uitest.cc

Issue 392005: NTP: Hide "Make this my home page" after setting the home page.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month 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
« no previous file with comments | « chrome/browser/dom_ui/new_tab_ui.cc ('k') | chrome/browser/resources/new_new_tab.css » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/test/ui/ui_test.h" 5 #include "chrome/test/ui/ui_test.h"
6 6
7 #include "base/file_path.h" 7 #include "base/file_path.h"
8 #include "chrome/app/chrome_dll_resource.h" 8 #include "chrome/app/chrome_dll_resource.h"
9 #include "chrome/browser/dom_ui/new_tab_ui.h" 9 #include "chrome/browser/dom_ui/new_tab_ui.h"
10 #include "chrome/common/pref_names.h" 10 #include "chrome/common/pref_names.h"
11 #include "chrome/common/pref_service.h" 11 #include "chrome/common/pref_service.h"
12 #include "chrome/test/automation/browser_proxy.h" 12 #include "chrome/test/automation/browser_proxy.h"
13 #include "chrome/test/automation/tab_proxy.h" 13 #include "chrome/test/automation/tab_proxy.h"
14 #include "chrome/test/automation/window_proxy.h" 14 #include "chrome/test/automation/window_proxy.h"
15 15
16 class NewTabUITest : public UITest { 16 class NewTabUITest : public UITest {
17 public: 17 public:
18 NewTabUITest() { 18 NewTabUITest() {
19 dom_automation_enabled_ = true; 19 dom_automation_enabled_ = true;
20 // Set home page to the empty string so that we can set the home page using
21 // preferences.
22 homepage_ = L"";
20 23
21 // Setup the DEFAULT_THEME profile (has fake history entries). 24 // Setup the DEFAULT_THEME profile (has fake history entries).
22 set_template_user_data(UITest::ComputeTypicalUserDataSource( 25 set_template_user_data(UITest::ComputeTypicalUserDataSource(
23 UITest::DEFAULT_THEME)); 26 UITest::DEFAULT_THEME));
24 } 27 }
25 }; 28 };
26 29
27 TEST_F(NewTabUITest, NTPHasThumbnails) { 30 TEST_F(NewTabUITest, NTPHasThumbnails) {
28 // Switch to the "new tab" tab, which should be any new tab after the 31 // Switch to the "new tab" tab, which should be any new tab after the
29 // first (the first is about:blank). 32 // first (the first is about:blank).
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 ASSERT_EQ(0, prefs.GetInteger(prefs::kNTPPrefVersion)); 99 ASSERT_EQ(0, prefs.GetInteger(prefs::kNTPPrefVersion));
97 100
98 bool migrated = NewTabUI::UpdateUserPrefsVersion(&prefs); 101 bool migrated = NewTabUI::UpdateUserPrefsVersion(&prefs);
99 ASSERT_TRUE(migrated); 102 ASSERT_TRUE(migrated);
100 ASSERT_EQ(NewTabUI::current_pref_version(), 103 ASSERT_EQ(NewTabUI::current_pref_version(),
101 prefs.GetInteger(prefs::kNTPPrefVersion)); 104 prefs.GetInteger(prefs::kNTPPrefVersion));
102 105
103 migrated = NewTabUI::UpdateUserPrefsVersion(&prefs); 106 migrated = NewTabUI::UpdateUserPrefsVersion(&prefs);
104 ASSERT_FALSE(migrated); 107 ASSERT_FALSE(migrated);
105 } 108 }
109
110 TEST_F(NewTabUITest, HomePageLink) {
111 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0));
112 ASSERT_TRUE(browser.get());
113
114 ASSERT_TRUE(
115 browser->SetBooleanPreference(prefs::kHomePageIsNewTabPage, false));
116
117 int tab_count = -1;
118 ASSERT_TRUE(browser->GetTabCount(&tab_count));
119 ASSERT_EQ(1, tab_count);
120
121 // Bring up a new tab page.
122 browser->ApplyAccelerator(IDC_NEW_TAB);
123 WaitUntilTabCount(2);
124 int load_time;
125 ASSERT_TRUE(automation()->WaitForInitialNewTabUILoad(&load_time));
126
127 scoped_refptr<TabProxy> tab = browser->GetActiveTab();
128
129 // TODO(arv): Extract common patterns for doing js testing.
130
131 // Fire click
132 // TODO(arv): Find screen position of element and use a lower level click
133 // emulation.
134 bool result;
135 ASSERT_TRUE(tab->ExecuteAndExtractBool(L"",
136 L"window.domAutomationController.send("
137 L"(function() {"
138 L" var e = document.createEvent('Event');"
139 L" e.initEvent('click', true, true);"
140 L" var el = document.querySelector('#set-as-home-page > *');"
141 L" el.dispatchEvent(e);"
142 L" return true;"
143 L"})()"
144 L")",
145 &result));
146 ASSERT_TRUE(result);
147
148 // Make sure set as home page element is hidden.
149 std::wstring style_display;
150 ASSERT_TRUE(tab->ExecuteAndExtractString(L"",
151 L"window.domAutomationController.send("
152 L"(function() {"
153 L" var el = document.querySelector('#set-as-home-page');"
154 L" return el.style.display;"
155 L"})()"
156 L")",
157 &style_display));
158 ASSERT_EQ(L"none", style_display);
159
160 // Make sure that the notification is visible
161 bool has_class;
162 ASSERT_TRUE(tab->ExecuteAndExtractBool(L"",
163 L"window.domAutomationController.send("
164 L"(function() {"
165 L" var el = document.querySelector('#notification');"
166 L" return hasClass(el, 'show');"
167 L"})()"
168 L")",
169 &has_class));
170 ASSERT_TRUE(has_class);
171
172 bool is_home_page;
173 ASSERT_TRUE(browser->GetBooleanPreference(prefs::kHomePageIsNewTabPage,
174 &is_home_page));
175 ASSERT_TRUE(is_home_page);
176 }
OLDNEW
« no previous file with comments | « chrome/browser/dom_ui/new_tab_ui.cc ('k') | chrome/browser/resources/new_new_tab.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698