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

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

Issue 12066003: Remove TabStripModel wrapper use. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: gtk Created 7 years, 10 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"
11 #include "chrome/browser/ui/browser_tabstrip.h"
12 #include "chrome/browser/ui/login/login_prompt.h" 11 #include "chrome/browser/ui/login/login_prompt.h"
12 #include "chrome/browser/ui/tabs/tab_strip_model.h"
13 #include "chrome/common/chrome_notification_types.h" 13 #include "chrome/common/chrome_notification_types.h"
14 #include "chrome/common/chrome_paths.h" 14 #include "chrome/common/chrome_paths.h"
15 #include "chrome/common/chrome_switches.h" 15 #include "chrome/common/chrome_switches.h"
16 #include "chrome/common/pref_names.h" 16 #include "chrome/common/pref_names.h"
17 #include "chrome/test/base/in_process_browser_test.h" 17 #include "chrome/test/base/in_process_browser_test.h"
18 #include "chrome/test/base/ui_test_utils.h" 18 #include "chrome/test/base/ui_test_utils.h"
19 #include "content/public/browser/notification_details.h" 19 #include "content/public/browser/notification_details.h"
20 #include "content/public/browser/notification_source.h" 20 #include "content/public/browser/notification_source.h"
21 #include "content/public/browser/web_contents.h" 21 #include "content/public/browser/web_contents.h"
22 #include "content/public/browser/web_contents_observer.h" 22 #include "content/public/browser/web_contents_observer.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 #endif 89 #endif
90 // Test that the browser can establish a WebSocket connection via a proxy 90 // Test that the browser can establish a WebSocket connection via a proxy
91 // that requires basic authentication. 91 // that requires basic authentication.
92 IN_PROC_BROWSER_TEST_F(ProxyBrowserTest, MAYBE_BasicAuthWSConnect) { 92 IN_PROC_BROWSER_TEST_F(ProxyBrowserTest, MAYBE_BasicAuthWSConnect) {
93 // Launch WebSocket server. 93 // Launch WebSocket server.
94 net::TestServer ws_server(net::TestServer::TYPE_WS, 94 net::TestServer ws_server(net::TestServer::TYPE_WS,
95 net::TestServer::kLocalhost, 95 net::TestServer::kLocalhost,
96 net::GetWebSocketTestDataDirectory()); 96 net::GetWebSocketTestDataDirectory());
97 ASSERT_TRUE(ws_server.Start()); 97 ASSERT_TRUE(ws_server.Start());
98 98
99 content::WebContents* tab = chrome::GetActiveWebContents(browser()); 99 content::WebContents* tab =
100 browser()->tab_strip_model()->GetActiveWebContents();
100 content::NavigationController* controller = &tab->GetController(); 101 content::NavigationController* controller = &tab->GetController();
101 content::NotificationRegistrar registrar; 102 content::NotificationRegistrar registrar;
102 // The proxy server will request basic authentication. 103 // The proxy server will request basic authentication.
103 // |observer| supplies the credential. 104 // |observer| supplies the credential.
104 LoginPromptObserver observer; 105 LoginPromptObserver observer;
105 registrar.Add(&observer, chrome::NOTIFICATION_AUTH_NEEDED, 106 registrar.Add(&observer, chrome::NOTIFICATION_AUTH_NEEDED,
106 content::Source<content::NavigationController>(controller)); 107 content::Source<content::NavigationController>(controller));
107 108
108 content::TitleWatcher watcher(tab, ASCIIToUTF16("PASS")); 109 content::TitleWatcher watcher(tab, ASCIIToUTF16("PASS"));
109 watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL")); 110 watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL"));
110 111
111 // Visit a page that tries to establish WebSocket connection. The title 112 // Visit a page that tries to establish WebSocket connection. The title
112 // of the page will be 'PASS' on success. 113 // of the page will be 'PASS' on success.
113 std::string scheme("http"); 114 std::string scheme("http");
114 GURL::Replacements replacements; 115 GURL::Replacements replacements;
115 replacements.SetSchemeStr(scheme); 116 replacements.SetSchemeStr(scheme);
116 ui_test_utils::NavigateToURL( 117 ui_test_utils::NavigateToURL(
117 browser(), 118 browser(),
118 ws_server.GetURL("connect_check.html").ReplaceComponents(replacements)); 119 ws_server.GetURL("connect_check.html").ReplaceComponents(replacements));
119 120
120 const string16 result = watcher.WaitAndGetTitle(); 121 const string16 result = watcher.WaitAndGetTitle();
121 EXPECT_TRUE(EqualsASCII(result, "PASS")); 122 EXPECT_TRUE(EqualsASCII(result, "PASS"));
122 EXPECT_TRUE(observer.auth_handled()); 123 EXPECT_TRUE(observer.auth_handled());
123 } 124 }
124 125
125 } // namespace 126 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/net/load_timing_observer_browsertest.cc ('k') | chrome/browser/page_cycler/page_cycler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698