| OLD | NEW |
| 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/common/url_constants.h" | 9 #include "chrome/common/url_constants.h" |
| 10 #include "chrome/test/base/in_process_browser_test.h" | 10 #include "chrome/test/base/in_process_browser_test.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 ASSERT_EQ("chrome-extension:", out); | 37 ASSERT_EQ("chrome-extension:", out); |
| 38 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractString( | 38 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractString( |
| 39 tab->GetRenderViewHost(), L"", | 39 tab->GetRenderViewHost(), L"", |
| 40 L"domAutomationController.send(location.pathname)", &out)); | 40 L"domAutomationController.send(location.pathname)", &out)); |
| 41 ASSERT_EQ("/main.html", out); | 41 ASSERT_EQ("/main.html", out); |
| 42 } | 42 } |
| 43 }; | 43 }; |
| 44 | 44 |
| 45 IN_PROC_BROWSER_TEST_F(BookmarksTest, ShouldRedirectToExtension) { | 45 IN_PROC_BROWSER_TEST_F(BookmarksTest, ShouldRedirectToExtension) { |
| 46 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIBookmarksURL)); | 46 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIBookmarksURL)); |
| 47 AssertIsBookmarksPage(browser()->GetSelectedWebContents()); | 47 AssertIsBookmarksPage(browser()->GetActiveWebContents()); |
| 48 } | 48 } |
| 49 | 49 |
| 50 IN_PROC_BROWSER_TEST_F(BookmarksTest, CommandOpensBookmarksTab) { | 50 IN_PROC_BROWSER_TEST_F(BookmarksTest, CommandOpensBookmarksTab) { |
| 51 ASSERT_EQ(1, browser()->tab_count()); | 51 ASSERT_EQ(1, browser()->tab_count()); |
| 52 | 52 |
| 53 // Bring up the bookmarks manager tab. | 53 // Bring up the bookmarks manager tab. |
| 54 OpenBookmarksManager(); | 54 OpenBookmarksManager(); |
| 55 ASSERT_EQ(1, browser()->tab_count()); | 55 ASSERT_EQ(1, browser()->tab_count()); |
| 56 AssertIsBookmarksPage(browser()->GetSelectedWebContents()); | 56 AssertIsBookmarksPage(browser()->GetActiveWebContents()); |
| 57 } | 57 } |
| 58 | 58 |
| 59 // If this flakes on Mac, use: http://crbug.com/87200 | 59 // If this flakes on Mac, use: http://crbug.com/87200 |
| 60 IN_PROC_BROWSER_TEST_F(BookmarksTest, CommandAgainGoesBackToBookmarksTab) { | 60 IN_PROC_BROWSER_TEST_F(BookmarksTest, CommandAgainGoesBackToBookmarksTab) { |
| 61 ui_test_utils::NavigateToURL( | 61 ui_test_utils::NavigateToURL( |
| 62 browser(), | 62 browser(), |
| 63 ui_test_utils::GetTestUrl(FilePath(), | 63 ui_test_utils::GetTestUrl(FilePath(), |
| 64 FilePath().AppendASCII("simple.html"))); | 64 FilePath().AppendASCII("simple.html"))); |
| 65 ASSERT_EQ(1, browser()->tab_count()); | 65 ASSERT_EQ(1, browser()->tab_count()); |
| 66 | 66 |
| 67 // Bring up the bookmarks manager tab. | 67 // Bring up the bookmarks manager tab. |
| 68 OpenBookmarksManager(); | 68 OpenBookmarksManager(); |
| 69 ASSERT_EQ(2, browser()->tab_count()); | 69 ASSERT_EQ(2, browser()->tab_count()); |
| 70 | 70 |
| 71 AssertIsBookmarksPage(browser()->GetSelectedWebContents()); | 71 AssertIsBookmarksPage(browser()->GetActiveWebContents()); |
| 72 | 72 |
| 73 // Switch to first tab and run command again. | 73 // Switch to first tab and run command again. |
| 74 browser()->ActivateTabAt(0, true); | 74 browser()->ActivateTabAt(0, true); |
| 75 browser()->OpenBookmarkManager(); | 75 browser()->OpenBookmarkManager(); |
| 76 | 76 |
| 77 // Ensure the bookmarks ui tab is active. | 77 // Ensure the bookmarks ui tab is active. |
| 78 ASSERT_EQ(1, browser()->active_index()); | 78 ASSERT_EQ(1, browser()->active_index()); |
| 79 ASSERT_EQ(2, browser()->tab_count()); | 79 ASSERT_EQ(2, browser()->tab_count()); |
| 80 } | 80 } |
| 81 | 81 |
| 82 IN_PROC_BROWSER_TEST_F(BookmarksTest, TwoCommandsOneTab) { | 82 IN_PROC_BROWSER_TEST_F(BookmarksTest, TwoCommandsOneTab) { |
| 83 content::TestNavigationObserver navigation_observer( | 83 content::TestNavigationObserver navigation_observer( |
| 84 content::NotificationService::AllSources()); | 84 content::NotificationService::AllSources()); |
| 85 browser()->OpenBookmarkManager(); | 85 browser()->OpenBookmarkManager(); |
| 86 browser()->OpenBookmarkManager(); | 86 browser()->OpenBookmarkManager(); |
| 87 navigation_observer.Wait(); | 87 navigation_observer.Wait(); |
| 88 | 88 |
| 89 ASSERT_EQ(1, browser()->tab_count()); | 89 ASSERT_EQ(1, browser()->tab_count()); |
| 90 } | 90 } |
| 91 | 91 |
| 92 IN_PROC_BROWSER_TEST_F(BookmarksTest, BookmarksLoaded) { | 92 IN_PROC_BROWSER_TEST_F(BookmarksTest, BookmarksLoaded) { |
| 93 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIBookmarksURL)); | 93 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIBookmarksURL)); |
| 94 ASSERT_EQ(1, browser()->tab_count()); | 94 ASSERT_EQ(1, browser()->tab_count()); |
| 95 AssertIsBookmarksPage(browser()->GetSelectedWebContents()); | 95 AssertIsBookmarksPage(browser()->GetActiveWebContents()); |
| 96 } | 96 } |
| OLD | NEW |