Add a minor text member to ui::MenuModel.
[chromium-blink-merge.git] / chrome / browser / net / websocket_browsertest.cc
blob444a03201853f1fac034d006aa0eb0b8fd028f27
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
3 // found in the LICENSE file.
5 #include "base/strings/string_util.h"
6 #include "base/strings/utf_string_conversions.h"
7 #include "chrome/browser/ui/browser.h"
8 #include "chrome/browser/ui/tabs/tab_strip_model.h"
9 #include "chrome/test/base/in_process_browser_test.h"
10 #include "chrome/test/base/ui_test_utils.h"
11 #include "content/public/test/browser_test_utils.h"
12 #include "net/base/test_data_directory.h"
13 #include "net/test/spawned_test_server/spawned_test_server.h"
15 namespace {
17 class WebSocketBrowserTest : public InProcessBrowserTest {
18 public:
19 WebSocketBrowserTest()
20 : ws_server_(net::SpawnedTestServer::TYPE_WS,
21 net::SpawnedTestServer::kLocalhost,
22 net::GetWebSocketTestDataDirectory()),
23 wss_server_(net::SpawnedTestServer::TYPE_WSS,
24 SSLOptions(SSLOptions::CERT_OK),
25 net::GetWebSocketTestDataDirectory()) {
28 protected:
29 net::SpawnedTestServer ws_server_;
30 net::SpawnedTestServer wss_server_;
32 private:
33 typedef net::SpawnedTestServer::SSLOptions SSLOptions;
35 DISALLOW_COPY_AND_ASSIGN(WebSocketBrowserTest);
38 // Test that the browser can handle a WebSocket frame split into multiple TCP
39 // segments.
40 IN_PROC_BROWSER_TEST_F(WebSocketBrowserTest, WebSocketSplitSegments) {
41 // Launch a WebSocket server.
42 ASSERT_TRUE(ws_server_.Start());
44 // Setup page title observer.
45 content::WebContents* tab =
46 browser()->tab_strip_model()->GetActiveWebContents();
47 content::TitleWatcher watcher(tab, ASCIIToUTF16("PASS"));
48 watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL"));
50 // Visit a HTTP page for testing.
51 std::string scheme("http");
52 GURL::Replacements replacements;
53 replacements.SetSchemeStr(scheme);
54 ui_test_utils::NavigateToURL(
55 browser(),
56 ws_server_.GetURL(
57 "split_packet_check.html").ReplaceComponents(replacements));
59 const string16 result = watcher.WaitAndGetTitle();
60 EXPECT_TRUE(EqualsASCII(result, "PASS"));
63 // Test that the browser can handle a WebSocket frame split into multiple SSL
64 // records. This test is flaky on Linux; see http://crbug.com/176867.
65 #if defined(OS_LINUX)
66 #define MAYBE_SecureWebSocketSplitRecords DISABLED_SecureWebSocketSplitRecords
67 #else
68 #define MAYBE_SecureWebSocketSplitRecords SecureWebSocketSplitRecords
69 #endif
70 IN_PROC_BROWSER_TEST_F(WebSocketBrowserTest,
71 MAYBE_SecureWebSocketSplitRecords) {
72 // Launch a secure WebSocket server.
73 ASSERT_TRUE(wss_server_.Start());
75 // Setup page title observer.
76 content::WebContents* tab =
77 browser()->tab_strip_model()->GetActiveWebContents();
78 content::TitleWatcher watcher(tab, ASCIIToUTF16("PASS"));
79 watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL"));
81 // Visit a HTTPS page for testing.
82 std::string scheme("https");
83 GURL::Replacements replacements;
84 replacements.SetSchemeStr(scheme);
85 ui_test_utils::NavigateToURL(
86 browser(),
87 wss_server_.GetURL(
88 "split_packet_check.html").ReplaceComponents(replacements));
90 const string16 result = watcher.WaitAndGetTitle();
91 EXPECT_TRUE(EqualsASCII(result, "PASS"));
94 } // namespace