| OLD | NEW |
| 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" |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 browser->RunCommand(IDC_NEW_TAB); | 123 browser->RunCommand(IDC_NEW_TAB); |
| 124 ASSERT_TRUE(browser->GetTabCount(&tab_count)); | 124 ASSERT_TRUE(browser->GetTabCount(&tab_count)); |
| 125 ASSERT_EQ(2, tab_count); | 125 ASSERT_EQ(2, tab_count); |
| 126 int load_time; | 126 int load_time; |
| 127 ASSERT_TRUE(automation()->WaitForInitialNewTabUILoad(&load_time)); | 127 ASSERT_TRUE(automation()->WaitForInitialNewTabUILoad(&load_time)); |
| 128 | 128 |
| 129 scoped_refptr<TabProxy> tab = browser->GetActiveTab(); | 129 scoped_refptr<TabProxy> tab = browser->GetActiveTab(); |
| 130 | 130 |
| 131 // TODO(arv): Extract common patterns for doing js testing. | 131 // TODO(arv): Extract common patterns for doing js testing. |
| 132 | 132 |
| 133 // Fire click | 133 // Fire click. Because tip service is turned off for testing, we first |
| 134 // force the "make this my home page" tip to appear. |
| 134 // TODO(arv): Find screen position of element and use a lower level click | 135 // TODO(arv): Find screen position of element and use a lower level click |
| 135 // emulation. | 136 // emulation. |
| 136 bool result; | 137 bool result; |
| 137 ASSERT_TRUE(tab->ExecuteAndExtractBool(L"", | 138 ASSERT_TRUE(tab->ExecuteAndExtractBool(L"", |
| 138 L"window.domAutomationController.send(" | 139 L"window.domAutomationController.send(" |
| 139 L"(function() {" | 140 L"(function() {" |
| 141 L" tipCache = [{\"set_homepage_tip\":\"Make this the home page\"}];" |
| 142 L" renderTip();" |
| 140 L" var e = document.createEvent('Event');" | 143 L" var e = document.createEvent('Event');" |
| 141 L" e.initEvent('click', true, true);" | 144 L" e.initEvent('click', true, true);" |
| 142 L" var el = document.querySelector('#set-as-home-page > *');" | 145 L" var el = document.querySelector('#tip-line > button');" |
| 143 L" el.dispatchEvent(e);" | 146 L" el.dispatchEvent(e);" |
| 144 L" return true;" | 147 L" return true;" |
| 145 L"})()" | 148 L"})()" |
| 146 L")", | 149 L")", |
| 147 &result)); | 150 &result)); |
| 148 ASSERT_TRUE(result); | 151 ASSERT_TRUE(result); |
| 149 | 152 |
| 150 // Make sure set as home page element is hidden. | 153 // Make sure text of "set as home page" tip has been removed. |
| 151 std::wstring style_display; | 154 std::wstring tip_text_content; |
| 152 ASSERT_TRUE(tab->ExecuteAndExtractString(L"", | 155 ASSERT_TRUE(tab->ExecuteAndExtractString(L"", |
| 153 L"window.domAutomationController.send(" | 156 L"window.domAutomationController.send(" |
| 154 L"(function() {" | 157 L"(function() {" |
| 155 L" var el = document.querySelector('#set-as-home-page');" | 158 L" var el = document.querySelector('#tip-line');" |
| 156 L" return el.style.display;" | 159 L" return el.textContent;" |
| 157 L"})()" | 160 L"})()" |
| 158 L")", | 161 L")", |
| 159 &style_display)); | 162 &tip_text_content)); |
| 160 ASSERT_EQ(L"none", style_display); | 163 ASSERT_EQ(L"", tip_text_content); |
| 161 | 164 |
| 162 // Make sure that the notification is visible | 165 // Make sure that the notification is visible |
| 163 bool has_class; | 166 bool has_class; |
| 164 ASSERT_TRUE(tab->ExecuteAndExtractBool(L"", | 167 ASSERT_TRUE(tab->ExecuteAndExtractBool(L"", |
| 165 L"window.domAutomationController.send(" | 168 L"window.domAutomationController.send(" |
| 166 L"(function() {" | 169 L"(function() {" |
| 167 L" var el = document.querySelector('#notification');" | 170 L" var el = document.querySelector('#notification');" |
| 168 L" return hasClass(el, 'show');" | 171 L" return hasClass(el, 'show');" |
| 169 L"})()" | 172 L"})()" |
| 170 L")", | 173 L")", |
| 171 &has_class)); | 174 &has_class)); |
| 172 ASSERT_TRUE(has_class); | 175 ASSERT_TRUE(has_class); |
| 173 | 176 |
| 174 bool is_home_page; | 177 bool is_home_page; |
| 175 ASSERT_TRUE(browser->GetBooleanPreference(prefs::kHomePageIsNewTabPage, | 178 ASSERT_TRUE(browser->GetBooleanPreference(prefs::kHomePageIsNewTabPage, |
| 176 &is_home_page)); | 179 &is_home_page)); |
| 177 ASSERT_TRUE(is_home_page); | 180 ASSERT_TRUE(is_home_page); |
| 178 } | 181 } |
| OLD | NEW |