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

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

Issue 456863003: Move more Sockets browser tests into appshell tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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
OLDNEW
(Empty)
1 // Copyright 2014 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.
4
5 #include "extensions/browser/api/dns/host_resolver_wrapper.h"
6 #include "extensions/browser/api/dns/mock_host_resolver_creator.h"
7 #include "extensions/browser/api/socket/socket_api.h"
8 #include "extensions/browser/api_test_utils.h"
9 #include "extensions/common/extension.h"
10 #include "extensions/common/test_util.h"
11 #include "extensions/shell/test/shell_test.h"
12
13 using extensions::api_test_utils::RunFunctionAndReturnSingleResult;
14
15 namespace extensions {
16
17 class SocketApiTest : public AppShellTest {};
18
19 IN_PROC_BROWSER_TEST_F(SocketApiTest, SocketUDPCreateGood) {
20 scoped_refptr<extensions::SocketCreateFunction> socket_create_function(
21 new extensions::SocketCreateFunction());
22 scoped_refptr<Extension> empty_extension = test_util::CreateEmptyExtension();
23
24 socket_create_function->set_extension(empty_extension.get());
25 socket_create_function->set_has_callback(true);
26
27 scoped_ptr<base::Value> result(RunFunctionAndReturnSingleResult(
28 socket_create_function.get(), "[\"udp\"]", browser_context()));
29 ASSERT_EQ(base::Value::TYPE_DICTIONARY, result->GetType());
30 base::DictionaryValue* value =
31 static_cast<base::DictionaryValue*>(result.get());
Yoyo Zhou 2014/08/11 23:32:57 No need to static cast. DictionaryValue* value = N
Daniel Nishi 2014/08/11 23:40:45 Done.
32 int socket_id = -1;
33 EXPECT_TRUE(value->GetInteger("socketId", &socket_id));
34 EXPECT_GT(socket_id, 0);
35 }
36
37 IN_PROC_BROWSER_TEST_F(SocketApiTest, SocketTCPCreateGood) {
38 scoped_refptr<extensions::SocketCreateFunction> socket_create_function(
39 new extensions::SocketCreateFunction());
40 scoped_refptr<Extension> empty_extension = test_util::CreateEmptyExtension();
41
42 socket_create_function->set_extension(empty_extension.get());
43 socket_create_function->set_has_callback(true);
44
45 scoped_ptr<base::Value> result(RunFunctionAndReturnSingleResult(
46 socket_create_function.get(), "[\"tcp\"]", browser_context()));
47 ASSERT_EQ(base::Value::TYPE_DICTIONARY, result->GetType());
48 base::DictionaryValue* value =
49 static_cast<base::DictionaryValue*>(result.get());
50 int socket_id = -1;
51 EXPECT_TRUE(value->GetInteger("socketId", &socket_id));
52 ASSERT_GT(socket_id, 0);
53 }
54
55 IN_PROC_BROWSER_TEST_F(SocketApiTest, GetNetworkList) {
56 scoped_refptr<extensions::SocketGetNetworkListFunction> socket_function(
57 new extensions::SocketGetNetworkListFunction());
58 scoped_refptr<Extension> empty_extension = test_util::CreateEmptyExtension();
59
60 socket_function->set_extension(empty_extension.get());
61 socket_function->set_has_callback(true);
62
63 scoped_ptr<base::Value> result(RunFunctionAndReturnSingleResult(
64 socket_function.get(), "[]", browser_context()));
65 ASSERT_EQ(base::Value::TYPE_LIST, result->GetType());
Yoyo Zhou 2014/08/11 23:32:57 Same, but for lists.
Daniel Nishi 2014/08/11 23:40:45 Done.
66
67 // If we're invoking socket tests, all we can confirm is that we have at
68 // least one address, but not what it is.
69 base::ListValue* value = static_cast<base::ListValue*>(result.get());
70 ASSERT_GT(value->GetSize(), 0U);
71 }
72
73 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698