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

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

Issue 10915002: Convert the history pyauto tests to a browser_tests. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: make DEPS clearer/cleaner after discussion with erikwright Created 8 years, 3 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
« no previous file with comments | « chrome/browser/policy/policy_browsertest.cc ('k') | chrome/test/base/ui_test_utils.h » ('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) 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/file_util.h" 5 #include "base/file_util.h"
6 #include "base/message_loop.h" 6 #include "base/message_loop.h"
7 #include "base/string16.h" 7 #include "base/string16.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/cancelable_request.h" 10 #include "chrome/browser/cancelable_request.h"
11 #include "chrome/browser/history/history.h" 11 #include "chrome/browser/history/history.h"
12 #include "chrome/browser/history/history_service_factory.h" 12 #include "chrome/browser/history/history_service_factory.h"
13 #include "chrome/browser/prefs/pref_service.h"
14 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/ui/browser.h" 14 #include "chrome/browser/ui/browser.h"
16 #include "chrome/browser/ui/browser_commands.h" 15 #include "chrome/browser/ui/browser_commands.h"
17 #include "chrome/browser/ui/browser_navigator.h" 16 #include "chrome/browser/ui/browser_navigator.h"
18 #include "chrome/browser/ui/browser_tabstrip.h" 17 #include "chrome/browser/ui/browser_tabstrip.h"
19 #include "chrome/browser/ui/browser_window.h" 18 #include "chrome/browser/ui/browser_window.h"
20 #include "chrome/browser/ui/chrome_pages.h" 19 #include "chrome/browser/ui/chrome_pages.h"
21 #include "chrome/browser/ui/find_bar/find_bar.h" 20 #include "chrome/browser/ui/find_bar/find_bar.h"
22 #include "chrome/browser/ui/find_bar/find_bar_controller.h" 21 #include "chrome/browser/ui/find_bar/find_bar_controller.h"
23 #include "chrome/browser/ui/find_bar/find_notification_details.h" 22 #include "chrome/browser/ui/find_bar/find_notification_details.h"
24 #include "chrome/browser/ui/find_bar/find_tab_helper.h" 23 #include "chrome/browser/ui/find_bar/find_tab_helper.h"
25 #include "chrome/browser/ui/tab_contents/tab_contents.h" 24 #include "chrome/browser/ui/tab_contents/tab_contents.h"
26 #include "chrome/browser/ui/tabs/tab_strip_model.h" 25 #include "chrome/browser/ui/tabs/tab_strip_model.h"
27 #include "chrome/common/pref_names.h"
28 #include "chrome/common/url_constants.h" 26 #include "chrome/common/url_constants.h"
29 #include "chrome/test/base/in_process_browser_test.h" 27 #include "chrome/test/base/in_process_browser_test.h"
30 #include "chrome/test/base/ui_test_utils.h" 28 #include "chrome/test/base/ui_test_utils.h"
31 #include "content/public/browser/download_manager.h" 29 #include "content/public/browser/download_manager.h"
32 #include "content/public/browser/notification_service.h" 30 #include "content/public/browser/notification_service.h"
33 #include "content/public/browser/notification_types.h" 31 #include "content/public/browser/notification_types.h"
34 #include "content/public/browser/render_view_host.h" 32 #include "content/public/browser/render_view_host.h"
35 #include "content/public/browser/web_contents.h" 33 #include "content/public/browser/web_contents.h"
36 #include "content/public/browser/web_contents_view.h" 34 #include "content/public/browser/web_contents_view.h"
37 #include "content/public/test/browser_test_utils.h" 35 #include "content/public/test/browser_test_utils.h"
38 #include "content/public/test/download_test_observer.h"
39 #include "net/base/net_util.h" 36 #include "net/base/net_util.h"
40 #include "ui/base/accelerators/accelerator.h" 37 #include "ui/base/accelerators/accelerator.h"
41 #include "ui/base/keycodes/keyboard_codes.h" 38 #include "ui/base/keycodes/keyboard_codes.h"
42 39
43 #if defined(TOOLKIT_VIEWS) 40 #if defined(TOOLKIT_VIEWS)
44 #include "chrome/browser/ui/views/find_bar_host.h" 41 #include "chrome/browser/ui/views/find_bar_host.h"
45 #include "ui/views/focus/focus_manager.h" 42 #include "ui/views/focus/focus_manager.h"
46 #include "ui/views/widget/widget.h" 43 #include "ui/views/widget/widget.h"
47 #elif defined(TOOLKIT_GTK) 44 #elif defined(TOOLKIT_GTK)
48 #include "chrome/browser/ui/gtk/slide_animator_gtk.h" 45 #include "chrome/browser/ui/gtk/slide_animator_gtk.h"
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 for (size_t i = 0; i < urls.size(); ++i) { 288 for (size_t i = 0; i < urls.size(); ++i) {
292 ui_test_utils::NavigateToURL(browser(), urls[i]); 289 ui_test_utils::NavigateToURL(browser(), urls[i]);
293 EXPECT_EQ(1, FindInPageWchar(tab, L"cat", kFwd, kIgnoreCase, NULL)); 290 EXPECT_EQ(1, FindInPageWchar(tab, L"cat", kFwd, kIgnoreCase, NULL));
294 EXPECT_EQ(0, FindInPageWchar(tab, L"bat", kFwd, kIgnoreCase, NULL)); 291 EXPECT_EQ(0, FindInPageWchar(tab, L"bat", kFwd, kIgnoreCase, NULL));
295 } 292 }
296 } 293 }
297 294
298 // Verify search for text within special URLs such as chrome:history, 295 // Verify search for text within special URLs such as chrome:history,
299 // chrome://downloads, data directory 296 // chrome://downloads, data directory
300 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, SearchWithinSpecialURL) { 297 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, SearchWithinSpecialURL) {
301 ScopedTempDir downloads_directory;
302 ASSERT_TRUE(downloads_directory.CreateUniqueTempDir());
303 browser()->profile()->GetPrefs()->SetFilePath(
304 prefs::kDownloadDefaultDirectory, downloads_directory.path());
305
306 TabContents* tab = chrome::GetActiveTabContents(browser()); 298 TabContents* tab = chrome::GetActiveTabContents(browser());
307 299
308 FilePath data_dir = ui_test_utils::GetTestFilePath(FilePath(), FilePath()); 300 FilePath data_dir = ui_test_utils::GetTestFilePath(FilePath(), FilePath());
309 ui_test_utils::NavigateToURL(browser(), net::FilePathToFileURL(data_dir)); 301 ui_test_utils::NavigateToURL(browser(), net::FilePathToFileURL(data_dir));
310 EXPECT_EQ(1, FindInPageWchar(tab, L"downloads", kFwd, kIgnoreCase, NULL)); 302 EXPECT_EQ(1, FindInPageWchar(tab, L"downloads", kFwd, kIgnoreCase, NULL));
311 303
312 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIHistoryURL)); 304 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIHistoryURL));
313 305
314 // The history page does an async request to the history service and then 306 // The history page does an async request to the history service and then
315 // updates the renderer. So we make a query as well, and by the time it comes 307 // updates the renderer. So we make a query as well, and by the time it comes
316 // back we know the data is on its way to the renderer. 308 // back we know the data is on its way to the renderer.
317 FlushHistoryService(); 309 FlushHistoryService();
318 310
319 string16 query(data_dir.LossyDisplayName()); 311 string16 query(data_dir.LossyDisplayName());
320 EXPECT_EQ(1, 312 EXPECT_EQ(1,
321 ui_test_utils::FindInPage(tab, query, kFwd, kIgnoreCase, NULL, 313 ui_test_utils::FindInPage(tab, query, kFwd, kIgnoreCase, NULL,
322 NULL)); 314 NULL));
323 315
324 // Start a download.
325 content::DownloadManager* download_manager =
326 content::BrowserContext::GetDownloadManager(browser()->profile());
327 scoped_ptr<content::DownloadTestObserver> observer(
328 new content::DownloadTestObserverTerminal(
329 download_manager, 1,
330 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_ACCEPT));
331
332 GURL download_url = ui_test_utils::GetTestUrl( 316 GURL download_url = ui_test_utils::GetTestUrl(
333 FilePath().AppendASCII("downloads"), 317 FilePath().AppendASCII("downloads"),
334 FilePath().AppendASCII("a_zip_file.zip")); 318 FilePath().AppendASCII("a_zip_file.zip"));
335 ui_test_utils::NavigateToURL(browser(), download_url); 319 ui_test_utils::DownloadURL(browser(), download_url);
336 observer->WaitForFinished();
337 320
338 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIDownloadsURL)); 321 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIDownloadsURL));
339 FlushHistoryService(); 322 FlushHistoryService();
340 EXPECT_EQ(1, 323 EXPECT_EQ(1,
341 FindInPageWchar(tab, ASCIIToWide(download_url.spec()).c_str(), kFwd, 324 FindInPageWchar(tab, ASCIIToWide(download_url.spec()).c_str(), kFwd,
342 kIgnoreCase, NULL)); 325 kIgnoreCase, NULL));
343 } 326 }
344 327
345 // Verify search selection coordinates. The data file used is set-up such that 328 // Verify search selection coordinates. The data file used is set-up such that
346 // the text occurs on the same line, and we verify their positions by verifying 329 // the text occurs on the same line, and we verify their positions by verifying
(...skipping 1129 matching lines...) Expand 10 before | Expand all | Expand 10 after
1476 content::RunAllPendingInMessageLoop(); // Needed on Linux. 1459 content::RunAllPendingInMessageLoop(); // Needed on Linux.
1477 EXPECT_TRUE(GetFindBarWindowInfo(&position, NULL)); 1460 EXPECT_TRUE(GetFindBarWindowInfo(&position, NULL));
1478 1461
1479 ui_test_utils::NavigateToURLWithDisposition( 1462 ui_test_utils::NavigateToURLWithDisposition(
1480 browser(), url, NEW_FOREGROUND_TAB, 1463 browser(), url, NEW_FOREGROUND_TAB,
1481 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 1464 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
1482 chrome::CloseTab(browser()); 1465 chrome::CloseTab(browser());
1483 EXPECT_TRUE(GetFindBarWindowInfo(&position2, NULL)); 1466 EXPECT_TRUE(GetFindBarWindowInfo(&position2, NULL));
1484 EXPECT_EQ(position, position2); 1467 EXPECT_EQ(position, position2);
1485 } 1468 }
OLDNEW
« no previous file with comments | « chrome/browser/policy/policy_browsertest.cc ('k') | chrome/test/base/ui_test_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698