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

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

Issue 8743017: Real (but naive) UDP socket sending. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Initial. Created 9 years 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/extensions/extension_apitest.h" 6 #include "chrome/browser/extensions/extension_apitest.h"
7 #include "chrome/browser/extensions/extension_function_test_utils.h" 7 #include "chrome/browser/extensions/extension_function_test_utils.h"
8 #include "chrome/browser/extensions/socket_api.h" 8 #include "chrome/browser/extensions/socket_api.h"
9 #include "chrome/common/chrome_switches.h" 9 #include "chrome/common/chrome_switches.h"
10 #include "chrome/test/base/in_process_browser_test.h" 10 #include "chrome/test/base/in_process_browser_test.h"
11 #include "chrome/test/base/ui_test_utils.h" 11 #include "chrome/test/base/ui_test_utils.h"
12 12
13 using namespace extension_function_test_utils; 13 using namespace extension_function_test_utils;
14 14
15 namespace { 15 namespace {
16 16
17 class SocketApiTest : public InProcessBrowserTest { 17 class SocketApiTest : public InProcessBrowserTest {
18 public:
19 virtual void SetUp() {
20 CommandLine::ForCurrentProcess()->AppendSwitch(
21 switches::kEnableExperimentalExtensionApis);
22 CommandLine::ForCurrentProcess()->AppendSwitch(
23 switches::kEnablePlatformApps);
24 }
18 }; 25 };
19 26
20 } 27 }
21 28
22 IN_PROC_BROWSER_TEST_F(SocketApiTest, SocketCreateGood) { 29 IN_PROC_BROWSER_TEST_F(SocketApiTest, SocketCreateGood) {
23 CommandLine::ForCurrentProcess()->AppendSwitch(
24 switches::kEnableExperimentalExtensionApis);
25 CommandLine::ForCurrentProcess()->AppendSwitch(
26 switches::kEnablePlatformApps);
27 scoped_refptr<extensions::SocketCreateFunction> socket_create_function( 30 scoped_refptr<extensions::SocketCreateFunction> socket_create_function(
28 new extensions::SocketCreateFunction()); 31 new extensions::SocketCreateFunction());
29 scoped_refptr<Extension> empty_extension(CreateEmptyExtension()); 32 scoped_refptr<Extension> empty_extension(CreateEmptyExtension());
30 33
31 socket_create_function->set_extension(empty_extension.get()); 34 socket_create_function->set_extension(empty_extension.get());
32 socket_create_function->set_has_callback(true); 35 socket_create_function->set_has_callback(true);
33 36
34 scoped_ptr<base::Value> result(RunFunctionAndReturnResult( 37 scoped_ptr<base::Value> result(RunFunctionAndReturnResult(
35 socket_create_function, "[\"udp\"]", browser(), NONE)); 38 socket_create_function, "[\"udp\"]", browser(), NONE));
36 ASSERT_EQ(base::Value::TYPE_DICTIONARY, result->GetType()); 39 ASSERT_EQ(base::Value::TYPE_DICTIONARY, result->GetType());
37 DictionaryValue *value = static_cast<DictionaryValue*>(result.get()); 40 DictionaryValue *value = static_cast<DictionaryValue*>(result.get());
38 int socketId = -1; 41 int socketId = -1;
39 EXPECT_TRUE(value->GetInteger("socketId", &socketId)); 42 EXPECT_TRUE(value->GetInteger("socketId", &socketId));
40 EXPECT_EQ(42, socketId); 43 EXPECT_EQ(42, socketId);
41 } 44 }
42 45
43 IN_PROC_BROWSER_TEST_F(SocketApiTest, SocketCreateBad) { 46 IN_PROC_BROWSER_TEST_F(SocketApiTest, SocketCreateBad) {
44 CommandLine::ForCurrentProcess()->AppendSwitch(
45 switches::kEnableExperimentalExtensionApis);
46 CommandLine::ForCurrentProcess()->AppendSwitch(
47 switches::kEnablePlatformApps);
48 scoped_refptr<extensions::SocketCreateFunction> socket_create_function( 47 scoped_refptr<extensions::SocketCreateFunction> socket_create_function(
49 new extensions::SocketCreateFunction()); 48 new extensions::SocketCreateFunction());
50 scoped_refptr<Extension> empty_extension(CreateEmptyExtension()); 49 scoped_refptr<Extension> empty_extension(CreateEmptyExtension());
51 50
52 socket_create_function->set_extension(empty_extension.get()); 51 socket_create_function->set_extension(empty_extension.get());
53 socket_create_function->set_has_callback(true); 52 socket_create_function->set_has_callback(true);
54 53
55 // TODO(miket): this test currently passes only because of artificial code 54 // TODO(miket): this test currently passes only because of artificial code
56 // that doesn't run in production. Fix this when we're able to. 55 // that doesn't run in production. Fix this when we're able to.
57 RunFunctionAndReturnError(socket_create_function, "[\"xxxx\"]", browser(), 56 RunFunctionAndReturnError(socket_create_function, "[\"xxxx\"]", browser(),
58 NONE); 57 NONE);
59 } 58 }
60 59
61 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, SocketExtension) { 60 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, SocketExtension) {
62 CommandLine::ForCurrentProcess()->AppendSwitch(
Mihai Parparita -not on Chrome 2011/12/01 23:39:32 This test doesn't inherit from SocketApiTest, so p
63 switches::kEnableExperimentalExtensionApis);
64 CommandLine::ForCurrentProcess()->AppendSwitch(
65 switches::kEnablePlatformApps);
66
67 ASSERT_TRUE(RunExtensionTest("socket/api")) << message_; 61 ASSERT_TRUE(RunExtensionTest("socket/api")) << message_;
68 } 62 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698