OLD | NEW |
(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/sockets_tcp/sockets_tcp_api.h" |
| 6 #include "extensions/browser/api_test_utils.h" |
| 7 #include "extensions/common/extension.h" |
| 8 #include "extensions/common/test_util.h" |
| 9 #include "extensions/shell/test/shell_test.h" |
| 10 |
| 11 using extensions::api_test_utils::RunFunctionAndReturnSingleResult; |
| 12 |
| 13 namespace extensions { |
| 14 |
| 15 class SocketsTcpApiTest : public AppShellTest {}; |
| 16 |
| 17 IN_PROC_BROWSER_TEST_F(SocketsTcpApiTest, SocketsTcpCreateGood) { |
| 18 scoped_refptr<extensions::core_api::SocketsTcpCreateFunction> |
| 19 socket_create_function( |
| 20 new extensions::core_api::SocketsTcpCreateFunction()); |
| 21 scoped_refptr<Extension> empty_extension = test_util::CreateEmptyExtension(); |
| 22 |
| 23 socket_create_function->set_extension(empty_extension.get()); |
| 24 socket_create_function->set_has_callback(true); |
| 25 |
| 26 scoped_ptr<base::Value> result(RunFunctionAndReturnSingleResult( |
| 27 socket_create_function.get(), "[]", browser_context())); |
| 28 |
| 29 ASSERT_EQ(base::Value::TYPE_DICTIONARY, result->GetType()); |
| 30 base::DictionaryValue* value = |
| 31 static_cast<base::DictionaryValue*>(result.get()); |
| 32 int socketId = -1; |
| 33 EXPECT_TRUE(value->GetInteger("socketId", &socketId)); |
| 34 ASSERT_TRUE(socketId > 0); |
| 35 } |
| 36 |
| 37 } // namespace extensions |
OLD | NEW |