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

Side by Side Diff: chrome/browser/ui/webui/bookmarks_ui_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, 4 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 "chrome/test/ui/ui_test.h" 5 #include "chrome/test/ui/ui_test.h"
6 6
7 #include "base/test/test_timeouts.h" 7 #include "base/test/test_timeouts.h"
8 #include "chrome/browser/ui/browser.h" 8 #include "chrome/browser/ui/browser.h"
9 #include "chrome/browser/ui/browser_tabstrip.h" 9 #include "chrome/browser/ui/browser_tabstrip.h"
10 #include "chrome/browser/ui/chrome_pages.h" 10 #include "chrome/browser/ui/chrome_pages.h"
11 #include "chrome/common/url_constants.h" 11 #include "chrome/common/url_constants.h"
12 #include "chrome/test/base/in_process_browser_test.h" 12 #include "chrome/test/base/in_process_browser_test.h"
13 #include "chrome/test/base/ui_test_utils.h" 13 #include "chrome/test/base/ui_test_utils.h"
14 #include "content/public/browser/notification_service.h" 14 #include "content/public/browser/notification_service.h"
15 #include "content/public/browser/web_contents.h" 15 #include "content/public/browser/web_contents.h"
16 #include "content/public/test/browser_test_utils.h"
16 #include "content/public/test/test_navigation_observer.h" 17 #include "content/public/test/test_navigation_observer.h"
17 18
18 class BookmarksTest : public InProcessBrowserTest { 19 class BookmarksTest : public InProcessBrowserTest {
19 public: 20 public:
20 BookmarksTest() {} 21 BookmarksTest() {}
21 22
22 void OpenBookmarksManager() { 23 void OpenBookmarksManager() {
23 content::TestNavigationObserver navigation_observer( 24 content::TestNavigationObserver navigation_observer(
24 content::NotificationService::AllSources(), NULL, 2); 25 content::NotificationService::AllSources(), NULL, 2);
25 26
26 // Bring up the bookmarks manager tab. 27 // Bring up the bookmarks manager tab.
27 chrome::ShowBookmarkManager(browser()); 28 chrome::ShowBookmarkManager(browser());
28 navigation_observer.Wait(); 29 navigation_observer.Wait();
29 } 30 }
30 31
31 void AssertIsBookmarksPage(content::WebContents* tab) { 32 void AssertIsBookmarksPage(content::WebContents* tab) {
32 GURL url; 33 GURL url;
33 std::string out; 34 std::string out;
34 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractString( 35 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractString(
35 tab->GetRenderViewHost(), L"", 36 tab->GetRenderViewHost(), L"",
36 L"domAutomationController.send(location.protocol)", &out)); 37 L"domAutomationController.send(location.protocol)", &out));
37 ASSERT_EQ("chrome-extension:", out); 38 ASSERT_EQ("chrome-extension:", out);
38 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractString( 39 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractString(
39 tab->GetRenderViewHost(), L"", 40 tab->GetRenderViewHost(), L"",
40 L"domAutomationController.send(location.pathname)", &out)); 41 L"domAutomationController.send(location.pathname)", &out));
41 ASSERT_EQ("/main.html", out); 42 ASSERT_EQ("/main.html", out);
42 } 43 }
43 }; 44 };
44 45
45 IN_PROC_BROWSER_TEST_F(BookmarksTest, ShouldRedirectToExtension) { 46 IN_PROC_BROWSER_TEST_F(BookmarksTest, ShouldRedirectToExtension) {
46 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIBookmarksURL)); 47 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIBookmarksURL));
47 AssertIsBookmarksPage(chrome::GetActiveWebContents(browser())); 48 AssertIsBookmarksPage(chrome::GetActiveWebContents(browser()));
48 } 49 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 navigation_observer.Wait(); 88 navigation_observer.Wait();
88 89
89 ASSERT_EQ(1, browser()->tab_count()); 90 ASSERT_EQ(1, browser()->tab_count());
90 } 91 }
91 92
92 IN_PROC_BROWSER_TEST_F(BookmarksTest, BookmarksLoaded) { 93 IN_PROC_BROWSER_TEST_F(BookmarksTest, BookmarksLoaded) {
93 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIBookmarksURL)); 94 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIBookmarksURL));
94 ASSERT_EQ(1, browser()->tab_count()); 95 ASSERT_EQ(1, browser()->tab_count());
95 AssertIsBookmarksPage(chrome::GetActiveWebContents(browser())); 96 AssertIsBookmarksPage(chrome::GetActiveWebContents(browser()));
96 } 97 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/pdf/pdf_browsertest.cc ('k') | chrome/browser/ui/webui/inspect_ui_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698