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

Side by Side Diff: chrome/browser/net/proxy_browsertest.cc

Issue 11085039: WebSocket test server migration on browser_tests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: browser_tests done Created 8 years, 2 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 | Annotate | Revision Log
OLDNEW
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/command_line.h" 5 #include "base/command_line.h"
6 #include "base/path_service.h" 6 #include "base/path_service.h"
7 #include "base/string_util.h" 7 #include "base/string_util.h"
8 #include "base/stringprintf.h" 8 #include "base/stringprintf.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/ui/browser.h" 10 #include "chrome/browser/ui/browser.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 #if defined(OS_CHROMEOS) 78 #if defined(OS_CHROMEOS)
79 // We bypass manually installed proxy for localhost on chromeos. 79 // We bypass manually installed proxy for localhost on chromeos.
80 #define MAYBE_BasicAuthWSConnect DISABLED_BasicAuthWSConnect 80 #define MAYBE_BasicAuthWSConnect DISABLED_BasicAuthWSConnect
81 #else 81 #else
82 #define MAYBE_BasicAuthWSConnect BasicAuthWSConnect 82 #define MAYBE_BasicAuthWSConnect BasicAuthWSConnect
83 #endif 83 #endif
84 // Test that the browser can establish a WebSocket connection via a proxy 84 // Test that the browser can establish a WebSocket connection via a proxy
85 // that requires basic authentication. 85 // that requires basic authentication.
86 IN_PROC_BROWSER_TEST_F(ProxyBrowserTest, MAYBE_BasicAuthWSConnect) { 86 IN_PROC_BROWSER_TEST_F(ProxyBrowserTest, MAYBE_BasicAuthWSConnect) {
87 // Launch WebSocket server. 87 // Launch WebSocket server.
88 content::TestWebSocketServer ws_server; 88 net::TestServer ws_server(net::TestServer::TYPE_WS,
89 int port = ws_server.UseRandomPort(); 89 net::TestServer::kLocalhost,
90 FilePath ws_root_dir; 90 FilePath(FILE_PATH_LITERAL("net"))
91 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &ws_root_dir)); 91 .Append(FILE_PATH_LITERAL("data"))
92 ASSERT_TRUE(ws_server.Start(ws_root_dir)); 92 .Append(FILE_PATH_LITERAL("websocket")));
Ryan Sleevi 2012/10/10 17:59:57 As per the comment on the other CL, using FILE_PAT
Takashi Toyoshima 2012/10/11 05:53:28 Done.
93 ASSERT_TRUE(ws_server.Start());
93 94
94 content::WebContents* tab = chrome::GetActiveWebContents(browser()); 95 content::WebContents* tab = chrome::GetActiveWebContents(browser());
95 content::NavigationController* controller = &tab->GetController(); 96 content::NavigationController* controller = &tab->GetController();
96 content::NotificationRegistrar registrar; 97 content::NotificationRegistrar registrar;
97 // The proxy server will request basic authentication. 98 // The proxy server will request basic authentication.
98 // |observer| supplies the credential. 99 // |observer| supplies the credential.
99 LoginPromptObserver observer; 100 LoginPromptObserver observer;
100 registrar.Add(&observer, chrome::NOTIFICATION_AUTH_NEEDED, 101 registrar.Add(&observer, chrome::NOTIFICATION_AUTH_NEEDED,
101 content::Source<content::NavigationController>(controller)); 102 content::Source<content::NavigationController>(controller));
102 103
103 content::TitleWatcher watcher(tab, ASCIIToUTF16("PASS")); 104 content::TitleWatcher watcher(tab, ASCIIToUTF16("PASS"));
104 watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL")); 105 watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL"));
105 106
106 // Visit a page that tries to establish WebSocket connection. The title 107 // Visit a page that tries to establish WebSocket connection. The title
107 // of the page will be 'PASS' on success. 108 // of the page will be 'PASS' on success.
108 // TODO(bashi): Add TestWebSocketServer::GetURL() instead creating url here. 109 ui_test_utils::NavigateToURL(browser(),
109 std::string url_path = 110 ws_server.GetAlternateURL("connect_check.html"));
110 StringPrintf("%s%d%s", "http://localhost:", port, "/ws.html");
111 ui_test_utils::NavigateToURL(browser(), GURL(url_path));
112 111
113 const string16 result = watcher.WaitAndGetTitle(); 112 const string16 result = watcher.WaitAndGetTitle();
114 EXPECT_TRUE(EqualsASCII(result, "PASS")); 113 EXPECT_TRUE(EqualsASCII(result, "PASS"));
115 EXPECT_TRUE(observer.auth_handled()); 114 EXPECT_TRUE(observer.auth_handled());
116 } 115 }
117 116
118 } // namespace 117 } // namespace
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ssl/ssl_browser_tests.cc » ('j') | chrome/browser/ssl/ssl_browser_tests.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698