| 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 "base/string_util.h" | 5 #include "base/string_util.h" |
| 6 #include "base/utf_string_conversions.h" | 6 #include "base/utf_string_conversions.h" |
| 7 #include "chrome/browser/ui/browser.h" | 7 #include "chrome/browser/ui/browser.h" |
| 8 #include "chrome/test/base/in_process_browser_test.h" | 8 #include "chrome/test/base/in_process_browser_test.h" |
| 9 #include "chrome/test/base/ui_test_utils.h" | 9 #include "chrome/test/base/ui_test_utils.h" |
| 10 #include "content/browser/web_contents/web_contents_impl.h" | 10 #include "content/browser/web_contents/web_contents_impl.h" |
| 11 #include "content/public/browser/notification_service.h" | 11 #include "content/public/browser/notification_service.h" |
| 12 #include "content/public/browser/notification_types.h" | |
| 13 #include "net/test/test_server.h" | 12 #include "net/test/test_server.h" |
| 14 | 13 |
| 15 class ResourceDispatcherHostBrowserTest : public InProcessBrowserTest { | 14 class ResourceDispatcherHostBrowserTest : public InProcessBrowserTest { |
| 16 public: | 15 public: |
| 17 ResourceDispatcherHostBrowserTest() { | 16 ResourceDispatcherHostBrowserTest() { |
| 18 EnableDOMAutomation(); | 17 EnableDOMAutomation(); |
| 19 } | 18 } |
| 20 | 19 |
| 21 protected: | 20 protected: |
| 22 content::RenderViewHost* render_view_host() { | 21 content::RenderViewHost* render_view_host() { |
| 23 return browser()->GetSelectedWebContents()->GetRenderViewHost(); | 22 return browser()->GetSelectedWebContents()->GetRenderViewHost(); |
| 24 } | 23 } |
| 25 | 24 |
| 26 bool GetPopupTitle(const GURL& url, string16* title); | 25 bool GetPopupTitle(const GURL& url, string16* title); |
| 27 }; | 26 }; |
| 28 | 27 |
| 29 bool ResourceDispatcherHostBrowserTest::GetPopupTitle(const GURL& url, | 28 bool ResourceDispatcherHostBrowserTest::GetPopupTitle(const GURL& url, |
| 30 string16* title) { | 29 string16* title) { |
| 31 ui_test_utils::NavigateToURL(browser(), url); | 30 ui_test_utils::NavigateToURL(browser(), url); |
| 32 | 31 |
| 33 ui_test_utils::WindowedNotificationObserver observer( | 32 ui_test_utils::WindowedTabAddedNotificationObserver observer( |
| 34 content::NOTIFICATION_TAB_ADDED, | |
| 35 content::NotificationService::AllSources()); | 33 content::NotificationService::AllSources()); |
| 36 | 34 |
| 37 // Create dynamic popup. | 35 // Create dynamic popup. |
| 38 if (!ui_test_utils::ExecuteJavaScript( | 36 if (!ui_test_utils::ExecuteJavaScript( |
| 39 render_view_host(), L"", L"OpenPopup();")) | 37 render_view_host(), L"", L"OpenPopup();")) |
| 40 return false; | 38 return false; |
| 41 | 39 |
| 42 observer.Wait(); | 40 observer.Wait(); |
| 43 | 41 |
| 44 std::set<Browser*> excluded; | 42 std::set<Browser*> excluded; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 67 // See http://crbug.com/5988 | 65 // See http://crbug.com/5988 |
| 68 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, DynamicTitle2) { | 66 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, DynamicTitle2) { |
| 69 ASSERT_TRUE(test_server()->Start()); | 67 ASSERT_TRUE(test_server()->Start()); |
| 70 | 68 |
| 71 GURL url(test_server()->GetURL("files/dynamic2.html")); | 69 GURL url(test_server()->GetURL("files/dynamic2.html")); |
| 72 string16 title; | 70 string16 title; |
| 73 ASSERT_TRUE(GetPopupTitle(url, &title)); | 71 ASSERT_TRUE(GetPopupTitle(url, &title)); |
| 74 EXPECT_TRUE(StartsWith(title, ASCIIToUTF16("My Dynamic Title"), true)) | 72 EXPECT_TRUE(StartsWith(title, ASCIIToUTF16("My Dynamic Title"), true)) |
| 75 << "Actual title: " << title; | 73 << "Actual title: " << title; |
| 76 } | 74 } |
| OLD | NEW |