Add ICU message format support
[chromium-blink-merge.git] / extensions / browser / api / socket / socket_apitest.cc
blobedc5a84541cd8022fd19a7239aa64ae8bdf10dae
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.
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"
13 using extensions::api_test_utils::RunFunctionAndReturnSingleResult;
15 namespace extensions {
17 class SocketApiTest : public AppShellTest {};
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();
24 socket_create_function->set_extension(empty_extension.get());
25 socket_create_function->set_has_callback(true);
27 scoped_ptr<base::Value> result(RunFunctionAndReturnSingleResult(
28 socket_create_function.get(), "[\"udp\"]", browser_context()));
29 base::DictionaryValue* value = NULL;
30 ASSERT_TRUE(result->GetAsDictionary(&value));
31 int socket_id = -1;
32 EXPECT_TRUE(value->GetInteger("socketId", &socket_id));
33 EXPECT_GT(socket_id, 0);
36 IN_PROC_BROWSER_TEST_F(SocketApiTest, SocketTCPCreateGood) {
37 scoped_refptr<extensions::SocketCreateFunction> socket_create_function(
38 new extensions::SocketCreateFunction());
39 scoped_refptr<Extension> empty_extension = test_util::CreateEmptyExtension();
41 socket_create_function->set_extension(empty_extension.get());
42 socket_create_function->set_has_callback(true);
44 scoped_ptr<base::Value> result(RunFunctionAndReturnSingleResult(
45 socket_create_function.get(), "[\"tcp\"]", browser_context()));
46 base::DictionaryValue* value = NULL;
47 ASSERT_TRUE(result->GetAsDictionary(&value));
48 int socket_id = -1;
49 EXPECT_TRUE(value->GetInteger("socketId", &socket_id));
50 ASSERT_GT(socket_id, 0);
53 IN_PROC_BROWSER_TEST_F(SocketApiTest, GetNetworkList) {
54 scoped_refptr<extensions::SocketGetNetworkListFunction> socket_function(
55 new extensions::SocketGetNetworkListFunction());
56 scoped_refptr<Extension> empty_extension = test_util::CreateEmptyExtension();
58 socket_function->set_extension(empty_extension.get());
59 socket_function->set_has_callback(true);
61 scoped_ptr<base::Value> result(RunFunctionAndReturnSingleResult(
62 socket_function.get(), "[]", browser_context()));
64 // If we're invoking socket tests, all we can confirm is that we have at
65 // least one address, but not what it is.
66 base::ListValue* value = NULL;
67 ASSERT_TRUE(result->GetAsList(&value));
68 ASSERT_GT(value->GetSize(), 0U);
71 } // namespace extensions