Index: chrome/browser/notifications/notification_browsertest.cc |
=================================================================== |
--- chrome/browser/notifications/notification_browsertest.cc (revision 137144) |
+++ chrome/browser/notifications/notification_browsertest.cc (working copy) |
@@ -2,69 +2,56 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "chrome/test/automation/automation_proxy.h" |
-#include "chrome/test/automation/browser_proxy.h" |
-#include "chrome/test/automation/tab_proxy.h" |
-#include "chrome/test/ui/ui_test.h" |
+#include "chrome/browser/infobars/infobar_tab_helper.h" |
+#include "chrome/browser/ui/browser.h" |
+#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
+#include "chrome/test/base/in_process_browser_test.h" |
+#include "chrome/test/base/ui_test_utils.h" |
+#include "content/public/browser/web_contents.h" |
#include "net/base/net_util.h" |
#include "net/test/test_server.h" |
-class NotificationsPermissionTest : public UITest { |
+class NotificationsPermissionTest : public InProcessBrowserTest { |
public: |
NotificationsPermissionTest() { |
- dom_automation_enabled_ = true; |
- show_window_ = true; |
+ EnableDOMAutomation(); |
} |
}; |
-// Flaky, http://crbug.com/62311 and http://crbug.com/74428. |
-TEST_F(NotificationsPermissionTest, DISABLED_TestUserGestureInfobar) { |
- net::TestServer test_server(net::TestServer::TYPE_HTTP, |
- net::TestServer::kLocalhost, |
- FilePath(FILE_PATH_LITERAL("chrome/test/data"))); |
- ASSERT_TRUE(test_server.Start()); |
+// If this flakes, use http://crbug.com/62311 and http://crbug.com/74428. |
+IN_PROC_BROWSER_TEST_F(NotificationsPermissionTest, TestUserGestureInfobar) { |
+ ASSERT_TRUE(test_server()->Start()); |
- scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); |
- ASSERT_TRUE(browser.get()); |
- scoped_refptr<TabProxy> tab(browser->GetActiveTab()); |
- ASSERT_TRUE(tab.get()); |
- ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, |
- tab->NavigateToURL(test_server.GetURL( |
- "files/notifications/notifications_request_function.html"))); |
- WaitUntilTabCount(1); |
+ ui_test_utils::NavigateToURL( |
+ browser(), |
+ test_server()->GetURL( |
+ "files/notifications/notifications_request_function.html")); |
// Request permission by calling request() while eval'ing an inline script; |
// That's considered a user gesture to webkit, and should produce an infobar. |
bool result; |
- ASSERT_TRUE(tab->ExecuteAndExtractBool( |
+ ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
+ browser()->GetSelectedWebContents()->GetRenderViewHost(), |
L"", |
L"window.domAutomationController.send(request());", |
&result)); |
EXPECT_TRUE(result); |
- EXPECT_TRUE(tab->WaitForInfoBarCount(1)); |
+ EXPECT_EQ(1U, browser()->GetTabContentsWrapperAt(0)->infobar_tab_helper()-> |
+ infobar_count()); |
} |
-// Flaky, http://crbug.com/62311. |
-TEST_F(NotificationsPermissionTest, DISABLED_TestNoUserGestureInfobar) { |
- net::TestServer test_server(net::TestServer::TYPE_HTTP, |
- net::TestServer::kLocalhost, |
- FilePath(FILE_PATH_LITERAL("chrome/test/data"))); |
- ASSERT_TRUE(test_server.Start()); |
+// If this flakes, use http://crbug.com/62311. |
+IN_PROC_BROWSER_TEST_F(NotificationsPermissionTest, TestNoUserGestureInfobar) { |
+ ASSERT_TRUE(test_server()->Start()); |
- scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); |
- ASSERT_TRUE(browser.get()); |
- scoped_refptr<TabProxy> tab(browser->GetActiveTab()); |
- ASSERT_TRUE(tab.get()); |
- |
// Load a page which just does a request; no user gesture should result |
// in no infobar. |
- ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, |
- tab->NavigateToURL(test_server.GetURL( |
- "files/notifications/notifications_request_inline.html"))); |
- WaitUntilTabCount(1); |
+ ui_test_utils::NavigateToURL( |
+ browser(), |
+ test_server()->GetURL( |
+ "files/notifications/notifications_request_inline.html")); |
- size_t info_bar_count; |
- ASSERT_TRUE(tab->GetInfoBarCount(&info_bar_count)); |
- EXPECT_EQ(0U, info_bar_count); |
+ EXPECT_EQ(0U, browser()->GetTabContentsWrapperAt(0)->infobar_tab_helper()-> |
+ infobar_count()); |
} |