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

Side by Side Diff: chrome/browser/notifications/notifications_interactive_uitest.cc

Issue 3034038: GTTF: Move more test server code from net/url_request/url_request_unittest.h (Closed)
Patch Set: hopefully final Created 10 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
OLDNEW
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 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/file_path.h" 5 #include "base/file_path.h"
6 #include "chrome/common/chrome_switches.h" 6 #include "chrome/common/chrome_switches.h"
7 #include "chrome/test/automation/browser_proxy.h" 7 #include "chrome/test/automation/browser_proxy.h"
8 #include "chrome/test/automation/tab_proxy.h" 8 #include "chrome/test/automation/tab_proxy.h"
9 #include "chrome/test/ui/ui_test.h" 9 #include "chrome/test/ui/ui_test.h"
10 #include "net/base/net_util.h" 10 #include "net/base/net_util.h"
11 #include "net/url_request/url_request_unittest.h" 11 #include "net/test/test_server.h"
12 12
13 class NotificationsPermissionTest : public UITest { 13 class NotificationsPermissionTest : public UITest {
14 public: 14 public:
15 NotificationsPermissionTest() { 15 NotificationsPermissionTest() {
16 dom_automation_enabled_ = true; 16 dom_automation_enabled_ = true;
17 show_window_ = true; 17 show_window_ = true;
18 } 18 }
19 }; 19 };
20 20
21 TEST_F(NotificationsPermissionTest, TestUserGestureInfobar) { 21 TEST_F(NotificationsPermissionTest, TestUserGestureInfobar) {
22 const wchar_t kDocRoot[] = L"chrome/test/data"; 22 const wchar_t kDocRoot[] = L"chrome/test/data";
23 scoped_refptr<HTTPTestServer> server(HTTPTestServer::CreateServer(kDocRoot)); 23 scoped_refptr<net::HTTPTestServer> server(
24 net::HTTPTestServer::CreateServer(kDocRoot));
24 ASSERT_TRUE(server.get() != NULL); 25 ASSERT_TRUE(server.get() != NULL);
25 26
26 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); 27 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0));
27 ASSERT_TRUE(browser.get()); 28 ASSERT_TRUE(browser.get());
28 scoped_refptr<TabProxy> tab(browser->GetActiveTab()); 29 scoped_refptr<TabProxy> tab(browser->GetActiveTab());
29 ASSERT_TRUE(tab.get()); 30 ASSERT_TRUE(tab.get());
30 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, 31 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS,
31 tab->NavigateToURL(server->TestServerPage( 32 tab->NavigateToURL(server->TestServerPage(
32 "files/notifications/notifications_request_function.html"))); 33 "files/notifications/notifications_request_function.html")));
33 WaitUntilTabCount(1); 34 WaitUntilTabCount(1);
34 35
35 // Request permission by calling request() while eval'ing an inline script; 36 // Request permission by calling request() while eval'ing an inline script;
36 // That's considered a user gesture to webkit, and should produce an infobar. 37 // That's considered a user gesture to webkit, and should produce an infobar.
37 bool result; 38 bool result;
38 ASSERT_TRUE(tab->ExecuteAndExtractBool( 39 ASSERT_TRUE(tab->ExecuteAndExtractBool(
39 L"", 40 L"",
40 L"window.domAutomationController.send(request());", 41 L"window.domAutomationController.send(request());",
41 &result)); 42 &result));
42 EXPECT_TRUE(result); 43 EXPECT_TRUE(result);
43 44
44 EXPECT_TRUE(tab->WaitForInfoBarCount(1, action_max_timeout_ms())); 45 EXPECT_TRUE(tab->WaitForInfoBarCount(1, action_max_timeout_ms()));
45 } 46 }
46 47
47 TEST_F(NotificationsPermissionTest, TestNoUserGestureInfobar) { 48 TEST_F(NotificationsPermissionTest, TestNoUserGestureInfobar) {
48 const wchar_t kDocRoot[] = L"chrome/test/data"; 49 const wchar_t kDocRoot[] = L"chrome/test/data";
49 scoped_refptr<HTTPTestServer> server(HTTPTestServer::CreateServer(kDocRoot)); 50 scoped_refptr<net::HTTPTestServer> server(
51 net::HTTPTestServer::CreateServer(kDocRoot));
50 ASSERT_TRUE(server.get() != NULL); 52 ASSERT_TRUE(server.get() != NULL);
51 53
52 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); 54 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0));
53 ASSERT_TRUE(browser.get()); 55 ASSERT_TRUE(browser.get());
54 scoped_refptr<TabProxy> tab(browser->GetActiveTab()); 56 scoped_refptr<TabProxy> tab(browser->GetActiveTab());
55 ASSERT_TRUE(tab.get()); 57 ASSERT_TRUE(tab.get());
56 58
57 // Load a page which just does a request; no user gesture should result 59 // Load a page which just does a request; no user gesture should result
58 // in no infobar. 60 // in no infobar.
59 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, 61 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS,
60 tab->NavigateToURL(server->TestServerPage( 62 tab->NavigateToURL(server->TestServerPage(
61 "files/notifications/notifications_request_inline.html"))); 63 "files/notifications/notifications_request_inline.html")));
62 WaitUntilTabCount(1); 64 WaitUntilTabCount(1);
63 65
64 int info_bar_count; 66 int info_bar_count;
65 ASSERT_TRUE(tab->GetInfoBarCount(&info_bar_count)); 67 ASSERT_TRUE(tab->GetInfoBarCount(&info_bar_count));
66 EXPECT_EQ(0, info_bar_count); 68 EXPECT_EQ(0, info_bar_count);
67 } 69 }
OLDNEW
« no previous file with comments | « chrome/browser/net/ftp_browsertest.cc ('k') | chrome/browser/printing/print_dialog_cloud_uitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698