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

Side by Side Diff: chrome/browser/extensions/api/socket/socket_apitest.cc

Issue 9834022: Expand usage of platform-apps flag and permission features. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Moved switch check to Extension::Create(). Created 8 years, 9 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"
6 #include "base/memory/ref_counted.h" 5 #include "base/memory/ref_counted.h"
7 #include "base/stringprintf.h" 6 #include "base/stringprintf.h"
8 #include "chrome/browser/extensions/api/socket/socket_api.h" 7 #include "chrome/browser/extensions/api/socket/socket_api.h"
9 #include "chrome/browser/extensions/extension_apitest.h" 8 #include "chrome/browser/extensions/extension_apitest.h"
10 #include "chrome/browser/extensions/extension_function_test_utils.h" 9 #include "chrome/browser/extensions/extension_function_test_utils.h"
10 #include "chrome/browser/extensions/extension_service.h"
11 #include "chrome/browser/extensions/extension_test_message_listener.h" 11 #include "chrome/browser/extensions/extension_test_message_listener.h"
12 #include "chrome/browser/ui/browser.h" 12 #include "chrome/browser/ui/browser.h"
13 #include "chrome/common/chrome_switches.h"
14 #include "chrome/test/base/in_process_browser_test.h" 13 #include "chrome/test/base/in_process_browser_test.h"
15 #include "chrome/test/base/ui_test_utils.h" 14 #include "chrome/test/base/ui_test_utils.h"
16 #include "net/test/test_server.h" 15 #include "net/test/test_server.h"
17 16
18 namespace utils = extension_function_test_utils; 17 namespace utils = extension_function_test_utils;
19 18
20 namespace { 19 namespace {
21 20
22 const std::string kHostname = "127.0.0.1"; 21 const std::string kHostname = "127.0.0.1";
23 const int kPort = 8888; 22 const int kPort = 8888;
24 23
25 class SocketApiTest : public ExtensionApiTest { 24 class SocketApiTest : public PlatformAppApiTest {
26 public: 25 public:
27 virtual void SetUpCommandLine(CommandLine* command_line) {
28 ExtensionApiTest::SetUpCommandLine(command_line);
29 command_line->AppendSwitch(switches::kEnableExperimentalExtensionApis);
30 command_line->AppendSwitch(switches::kEnablePlatformApps);
31 }
32
33 static std::string GenerateCreateFunctionArgs(const std::string& protocol, 26 static std::string GenerateCreateFunctionArgs(const std::string& protocol,
34 const std::string& address, 27 const std::string& address,
35 int port) { 28 int port) {
36 return base::StringPrintf("[\"%s\", \"%s\", %d]", protocol.c_str(), 29 return base::StringPrintf("[\"%s\", \"%s\", %d]", protocol.c_str(),
37 address.c_str(), port); 30 address.c_str(), port);
38 } 31 }
39 }; 32 };
40 33
34 } // namespace
35
36 IN_PROC_BROWSER_TEST_F(SocketApiTest, VerifyPermissions) {
37 VerifyPermissions(test_data_dir_.AppendASCII("socket/api"));
41 } 38 }
42 39
43 IN_PROC_BROWSER_TEST_F(SocketApiTest, SocketUDPCreateGood) { 40 IN_PROC_BROWSER_TEST_F(SocketApiTest, SocketUDPCreateGood) {
44 scoped_refptr<extensions::SocketCreateFunction> socket_create_function( 41 scoped_refptr<extensions::SocketCreateFunction> socket_create_function(
45 new extensions::SocketCreateFunction()); 42 new extensions::SocketCreateFunction());
46 scoped_refptr<Extension> empty_extension(utils::CreateEmptyExtension()); 43 scoped_refptr<Extension> empty_extension(utils::CreateEmptyExtension());
47 44
48 socket_create_function->set_extension(empty_extension.get()); 45 socket_create_function->set_extension(empty_extension.get());
49 socket_create_function->set_has_callback(true); 46 socket_create_function->set_has_callback(true);
50 47
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 131
135 ExtensionTestMessageListener listener("info_please", true); 132 ExtensionTestMessageListener listener("info_please", true);
136 133
137 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("socket/api"))); 134 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("socket/api")));
138 EXPECT_TRUE(listener.WaitUntilSatisfied()); 135 EXPECT_TRUE(listener.WaitUntilSatisfied());
139 listener.Reply( 136 listener.Reply(
140 base::StringPrintf("tcp:%s:%d", host_port_pair.host().c_str(), port)); 137 base::StringPrintf("tcp:%s:%d", host_port_pair.host().c_str(), port));
141 138
142 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); 139 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
143 } 140 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698