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