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

Side by Side Diff: chrome/browser/ui/find_bar/find_bar_host_browsertest.cc

Issue 10795090: Move ExecuteJavaScript functions from ui_test_utils.h to browser_test_utils.h so they can be reused… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 5 months 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/message_loop.h" 5 #include "base/message_loop.h"
6 #include "base/string16.h" 6 #include "base/string16.h"
7 #include "base/string_util.h" 7 #include "base/string_util.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/ui/browser.h" 10 #include "chrome/browser/ui/browser.h"
11 #include "chrome/browser/ui/browser_commands.h" 11 #include "chrome/browser/ui/browser_commands.h"
12 #include "chrome/browser/ui/browser_navigator.h" 12 #include "chrome/browser/ui/browser_navigator.h"
13 #include "chrome/browser/ui/browser_tabstrip.h" 13 #include "chrome/browser/ui/browser_tabstrip.h"
14 #include "chrome/browser/ui/browser_window.h" 14 #include "chrome/browser/ui/browser_window.h"
15 #include "chrome/browser/ui/chrome_pages.h" 15 #include "chrome/browser/ui/chrome_pages.h"
16 #include "chrome/browser/ui/find_bar/find_bar.h" 16 #include "chrome/browser/ui/find_bar/find_bar.h"
17 #include "chrome/browser/ui/find_bar/find_bar_controller.h" 17 #include "chrome/browser/ui/find_bar/find_bar_controller.h"
18 #include "chrome/browser/ui/find_bar/find_notification_details.h" 18 #include "chrome/browser/ui/find_bar/find_notification_details.h"
19 #include "chrome/browser/ui/find_bar/find_tab_helper.h" 19 #include "chrome/browser/ui/find_bar/find_tab_helper.h"
20 #include "chrome/browser/ui/tab_contents/tab_contents.h" 20 #include "chrome/browser/ui/tab_contents/tab_contents.h"
21 #include "chrome/browser/ui/tabs/tab_strip_model.h" 21 #include "chrome/browser/ui/tabs/tab_strip_model.h"
22 #include "chrome/common/url_constants.h" 22 #include "chrome/common/url_constants.h"
23 #include "chrome/test/base/in_process_browser_test.h" 23 #include "chrome/test/base/in_process_browser_test.h"
24 #include "chrome/test/base/ui_test_utils.h" 24 #include "chrome/test/base/ui_test_utils.h"
25 #include "content/public/browser/notification_service.h" 25 #include "content/public/browser/notification_service.h"
26 #include "content/public/browser/notification_types.h" 26 #include "content/public/browser/notification_types.h"
27 #include "content/public/browser/render_view_host.h" 27 #include "content/public/browser/render_view_host.h"
28 #include "content/public/browser/web_contents.h" 28 #include "content/public/browser/web_contents.h"
29 #include "content/public/browser/web_contents_view.h" 29 #include "content/public/browser/web_contents_view.h"
30 #include "content/public/test/browser_test_utils.h"
30 #include "ui/base/accelerators/accelerator.h" 31 #include "ui/base/accelerators/accelerator.h"
31 #include "ui/base/keycodes/keyboard_codes.h" 32 #include "ui/base/keycodes/keyboard_codes.h"
32 33
33 #if defined(TOOLKIT_VIEWS) 34 #if defined(TOOLKIT_VIEWS)
34 #include "chrome/browser/ui/views/find_bar_host.h" 35 #include "chrome/browser/ui/views/find_bar_host.h"
35 #include "ui/views/focus/focus_manager.h" 36 #include "ui/views/focus/focus_manager.h"
36 #include "ui/views/widget/widget.h" 37 #include "ui/views/widget/widget.h"
37 #elif defined(TOOLKIT_GTK) 38 #elif defined(TOOLKIT_GTK)
38 #include "chrome/browser/ui/gtk/slide_animator_gtk.h" 39 #include "chrome/browser/ui/gtk/slide_animator_gtk.h"
39 #elif defined(OS_MACOSX) 40 #elif defined(OS_MACOSX)
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 EXPECT_EQ(0, FindInPageWchar(tab, L"hreggvi\u00F0ur", 252 EXPECT_EQ(0, FindInPageWchar(tab, L"hreggvi\u00F0ur",
252 kFwd, kCaseSensitive, &ordinal)); 253 kFwd, kCaseSensitive, &ordinal));
253 EXPECT_EQ(0, ordinal); 254 EXPECT_EQ(0, ordinal);
254 } 255 }
255 256
256 // Specifying a prototype so that we can add the WARN_UNUSED_RESULT attribute. 257 // Specifying a prototype so that we can add the WARN_UNUSED_RESULT attribute.
257 bool FocusedOnPage(WebContents* web_contents, std::string* result) 258 bool FocusedOnPage(WebContents* web_contents, std::string* result)
258 WARN_UNUSED_RESULT; 259 WARN_UNUSED_RESULT;
259 260
260 bool FocusedOnPage(WebContents* web_contents, std::string* result) { 261 bool FocusedOnPage(WebContents* web_contents, std::string* result) {
261 return ui_test_utils::ExecuteJavaScriptAndExtractString( 262 return content::ExecuteJavaScriptAndExtractString(
262 web_contents->GetRenderViewHost(), 263 web_contents->GetRenderViewHost(),
263 L"", 264 L"",
264 L"window.domAutomationController.send(getFocusedElement());", 265 L"window.domAutomationController.send(getFocusedElement());",
265 result); 266 result);
266 } 267 }
267 268
268 // This tests the FindInPage end-state, in other words: what is focused when you 269 // This tests the FindInPage end-state, in other words: what is focused when you
269 // close the Find box (ie. if you find within a link the link should be 270 // close the Find box (ie. if you find within a link the link should be
270 // focused). 271 // focused).
271 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindInPageEndState) { 272 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindInPageEndState) {
(...skipping 22 matching lines...) Expand all
294 // Verify that the link is focused. 295 // Verify that the link is focused.
295 ASSERT_TRUE(FocusedOnPage(tab_contents->web_contents(), &result)); 296 ASSERT_TRUE(FocusedOnPage(tab_contents->web_contents(), &result));
296 EXPECT_STREQ("link1", result.c_str()); 297 EXPECT_STREQ("link1", result.c_str());
297 298
298 // Search for a text that exists within a link on the page. 299 // Search for a text that exists within a link on the page.
299 EXPECT_EQ(1, FindInPageWchar(tab_contents, L"Google", 300 EXPECT_EQ(1, FindInPageWchar(tab_contents, L"Google",
300 kFwd, kIgnoreCase, &ordinal)); 301 kFwd, kIgnoreCase, &ordinal));
301 EXPECT_EQ(1, ordinal); 302 EXPECT_EQ(1, ordinal);
302 303
303 // Move the selection to link 1, after searching. 304 // Move the selection to link 1, after searching.
304 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractString( 305 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractString(
305 tab_contents->web_contents()->GetRenderViewHost(), 306 tab_contents->web_contents()->GetRenderViewHost(),
306 L"", 307 L"",
307 L"window.domAutomationController.send(selectLink1());", 308 L"window.domAutomationController.send(selectLink1());",
308 &result)); 309 &result));
309 310
310 // End the find session. 311 // End the find session.
311 tab_contents-> 312 tab_contents->
312 find_tab_helper()->StopFinding(FindBarController::kKeepSelectionOnPage); 313 find_tab_helper()->StopFinding(FindBarController::kKeepSelectionOnPage);
313 314
314 // Verify that link2 is not focused. 315 // Verify that link2 is not focused.
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 TabContents* tab = chrome::GetActiveTabContents(browser()); 365 TabContents* tab = chrome::GetActiveTabContents(browser());
365 ASSERT_TRUE(NULL != tab); 366 ASSERT_TRUE(NULL != tab);
366 int ordinal = 0; 367 int ordinal = 0;
367 EXPECT_EQ(4, FindInPageWchar(tab, 368 EXPECT_EQ(4, FindInPageWchar(tab,
368 L"google", 369 L"google",
369 kFwd, kIgnoreCase, &ordinal)); 370 kFwd, kIgnoreCase, &ordinal));
370 EXPECT_EQ(1, ordinal); 371 EXPECT_EQ(1, ordinal);
371 372
372 // Move the selection to link 1, after searching. 373 // Move the selection to link 1, after searching.
373 std::string result; 374 std::string result;
374 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractString( 375 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractString(
375 tab->web_contents()->GetRenderViewHost(), 376 tab->web_contents()->GetRenderViewHost(),
376 L"", 377 L"",
377 L"window.domAutomationController.send(selectLink1());", 378 L"window.domAutomationController.send(selectLink1());",
378 &result)); 379 &result));
379 380
380 // Do a find-next after the selection. This should move forward 381 // Do a find-next after the selection. This should move forward
381 // from there to the 3rd instance of 'google'. 382 // from there to the 3rd instance of 'google'.
382 EXPECT_EQ(4, FindInPageWchar(tab, 383 EXPECT_EQ(4, FindInPageWchar(tab,
383 L"google", 384 L"google",
384 kFwd, kIgnoreCase, &ordinal)); 385 kFwd, kIgnoreCase, &ordinal));
(...skipping 865 matching lines...) Expand 10 before | Expand all | Expand 10 after
1250 ui_test_utils::RunAllPendingInMessageLoop(); // Needed on Linux. 1251 ui_test_utils::RunAllPendingInMessageLoop(); // Needed on Linux.
1251 EXPECT_TRUE(GetFindBarWindowInfo(&position, NULL)); 1252 EXPECT_TRUE(GetFindBarWindowInfo(&position, NULL));
1252 1253
1253 ui_test_utils::NavigateToURLWithDisposition( 1254 ui_test_utils::NavigateToURLWithDisposition(
1254 browser(), url, NEW_FOREGROUND_TAB, 1255 browser(), url, NEW_FOREGROUND_TAB,
1255 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 1256 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
1256 chrome::CloseTab(browser()); 1257 chrome::CloseTab(browser());
1257 EXPECT_TRUE(GetFindBarWindowInfo(&position2, NULL)); 1258 EXPECT_TRUE(GetFindBarWindowInfo(&position2, NULL));
1258 EXPECT_EQ(position, position2); 1259 EXPECT_EQ(position, position2);
1259 } 1260 }
OLDNEW
« no previous file with comments | « chrome/browser/ssl/ssl_browser_tests.cc ('k') | chrome/browser/ui/panels/old_panel_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698