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

Side by Side Diff: chrome/browser/extensions/api/sockets_tcp/sockets_tcp_apitest.cc

Issue 76403004: An implementation of chrome.socket.secure(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: An integration test, and some nits fixed. Created 6 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/memory/ref_counted.h" 5 #include "base/memory/ref_counted.h"
6 #include "base/path_service.h" 6 #include "base/path_service.h"
7 #include "base/strings/stringprintf.h" 7 #include "base/strings/stringprintf.h"
8 #include "chrome/browser/extensions/api/dns/host_resolver_wrapper.h" 8 #include "chrome/browser/extensions/api/dns/host_resolver_wrapper.h"
9 #include "chrome/browser/extensions/api/dns/mock_host_resolver_creator.h" 9 #include "chrome/browser/extensions/api/dns/mock_host_resolver_creator.h"
10 #include "chrome/browser/extensions/api/sockets_tcp/sockets_tcp_api.h" 10 #include "chrome/browser/extensions/api/sockets_tcp/sockets_tcp_api.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 scoped_ptr<base::Value> result(utils::RunFunctionAndReturnSingleResult( 75 scoped_ptr<base::Value> result(utils::RunFunctionAndReturnSingleResult(
76 socket_create_function.get(), "[]", browser(), utils::NONE)); 76 socket_create_function.get(), "[]", browser(), utils::NONE));
77 ASSERT_EQ(base::Value::TYPE_DICTIONARY, result->GetType()); 77 ASSERT_EQ(base::Value::TYPE_DICTIONARY, result->GetType());
78 base::DictionaryValue *value = 78 base::DictionaryValue *value =
79 static_cast<base::DictionaryValue*>(result.get()); 79 static_cast<base::DictionaryValue*>(result.get());
80 int socketId = -1; 80 int socketId = -1;
81 EXPECT_TRUE(value->GetInteger("socketId", &socketId)); 81 EXPECT_TRUE(value->GetInteger("socketId", &socketId));
82 ASSERT_TRUE(socketId > 0); 82 ASSERT_TRUE(socketId > 0);
83 } 83 }
84 84
85 IN_PROC_BROWSER_TEST_F(SocketsTcpApiTest, SocketTcpExtension) { 85 IN_PROC_BROWSER_TEST_F(SocketsTcpApiTest, SocketTcpExtension) {
Ryan Sleevi 2014/02/04 22:28:14 Rather than modifying the existing test, you shoul
lally 2014/02/11 22:05:35 Done.
86 scoped_ptr<net::SpawnedTestServer> test_server( 86 scoped_ptr<net::SpawnedTestServer> test_tcp_server(
87 new net::SpawnedTestServer( 87 new net::SpawnedTestServer(
88 net::SpawnedTestServer::TYPE_TCP_ECHO, 88 net::SpawnedTestServer::TYPE_TCP_ECHO,
89 net::SpawnedTestServer::kLocalhost, 89 net::SpawnedTestServer::kLocalhost,
90 base::FilePath(FILE_PATH_LITERAL("net/data")))); 90 base::FilePath(FILE_PATH_LITERAL("net/data"))));
91 EXPECT_TRUE(test_server->Start()); 91 scoped_ptr<net::SpawnedTestServer> test_https_server(
92 new net::SpawnedTestServer(
93 net::SpawnedTestServer::TYPE_HTTPS,
94 net::BaseTestServer::SSLOptions(),
95 base::FilePath(FILE_PATH_LITERAL("net/data"))));
96 // Start them in parallel.
97 EXPECT_TRUE(test_tcp_server->StartInBackground());
98 EXPECT_TRUE(test_https_server->StartInBackground());
99 EXPECT_TRUE(test_tcp_server->BlockUntilStarted());
100 EXPECT_TRUE(test_https_server->BlockUntilStarted());
92 101
93 net::HostPortPair host_port_pair = test_server->host_port_pair(); 102 net::HostPortPair tcp_host_port_pair = test_tcp_server->host_port_pair();
94 int port = host_port_pair.port(); 103 int tcp_port = tcp_host_port_pair.port();
95 ASSERT_TRUE(port > 0); 104 ASSERT_TRUE(tcp_port > 0);
105
106 net::HostPortPair https_host_port_pair = test_https_server->host_port_pair();
107 int https_port = https_host_port_pair.port();
108 ASSERT_TRUE(https_port > 0);
96 109
97 // Test that connect() is properly resolving hostnames. 110 // Test that connect() is properly resolving hostnames.
98 host_port_pair.set_host("lOcAlHoSt"); 111 tcp_host_port_pair.set_host("lOcAlHoSt");
99 112
100 ResultCatcher catcher; 113 ResultCatcher catcher;
101 catcher.RestrictToProfile(browser()->profile()); 114 catcher.RestrictToProfile(browser()->profile());
102 115
103 ExtensionTestMessageListener listener("info_please", true); 116 ExtensionTestMessageListener listener("info_please", true);
104 117
105 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("sockets_tcp/api"))); 118 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("sockets_tcp/api")));
106 EXPECT_TRUE(listener.WaitUntilSatisfied()); 119 EXPECT_TRUE(listener.WaitUntilSatisfied());
107 listener.Reply( 120 listener.Reply(
108 base::StringPrintf("tcp:%s:%d", host_port_pair.host().c_str(), port)); 121 base::StringPrintf("tcp:%s:%d,https:%s:%d",
122 tcp_host_port_pair.host().c_str(), tcp_port,
123 https_host_port_pair.host().c_str(), https_port));
109 124
110 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); 125 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
111 } 126 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698