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

Side by Side Diff: extensions/browser/api/sockets_tcp_server/sockets_tcp_server_apitest.cc

Issue 1308013005: Add scoped_ptr-safe base::Value to Dictionary/List conversion functions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Made conversions static members. Created 5 years, 3 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
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/memory/ref_counted.h" 5 #include "base/memory/ref_counted.h"
6 #include "base/strings/stringprintf.h" 6 #include "base/strings/stringprintf.h"
7 #include "extensions/browser/api/dns/host_resolver_wrapper.h" 7 #include "extensions/browser/api/dns/host_resolver_wrapper.h"
8 #include "extensions/browser/api/dns/mock_host_resolver_creator.h" 8 #include "extensions/browser/api/dns/mock_host_resolver_creator.h"
9 #include "extensions/browser/api/sockets_tcp_server/sockets_tcp_server_api.h" 9 #include "extensions/browser/api/sockets_tcp_server/sockets_tcp_server_api.h"
10 #include "extensions/browser/api_test_utils.h" 10 #include "extensions/browser/api_test_utils.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 new api::SocketsTcpServerCreateFunction()); 55 new api::SocketsTcpServerCreateFunction());
56 scoped_refptr<Extension> empty_extension(test_util::CreateEmptyExtension()); 56 scoped_refptr<Extension> empty_extension(test_util::CreateEmptyExtension());
57 57
58 socket_create_function->set_extension(empty_extension.get()); 58 socket_create_function->set_extension(empty_extension.get());
59 socket_create_function->set_has_callback(true); 59 socket_create_function->set_has_callback(true);
60 60
61 scoped_ptr<base::Value> result( 61 scoped_ptr<base::Value> result(
62 api_test_utils::RunFunctionAndReturnSingleResult( 62 api_test_utils::RunFunctionAndReturnSingleResult(
63 socket_create_function.get(), "[]", browser_context())); 63 socket_create_function.get(), "[]", browser_context()));
64 ASSERT_EQ(base::Value::TYPE_DICTIONARY, result->GetType()); 64 ASSERT_EQ(base::Value::TYPE_DICTIONARY, result->GetType());
65 base::DictionaryValue* value = 65 scoped_ptr<base::DictionaryValue> value =
66 static_cast<base::DictionaryValue*>(result.get()); 66 base::DictionaryValue::From(result.Pass());
67 int socketId = -1; 67 int socketId = -1;
68 EXPECT_TRUE(value->GetInteger("socketId", &socketId)); 68 EXPECT_TRUE(value->GetInteger("socketId", &socketId));
69 ASSERT_TRUE(socketId > 0); 69 ASSERT_TRUE(socketId > 0);
70 } 70 }
71 71
72 IN_PROC_BROWSER_TEST_F(SocketsTcpServerApiTest, SocketTCPServerExtension) { 72 IN_PROC_BROWSER_TEST_F(SocketsTcpServerApiTest, SocketTCPServerExtension) {
73 ResultCatcher catcher; 73 ResultCatcher catcher;
74 catcher.RestrictToBrowserContext(browser_context()); 74 catcher.RestrictToBrowserContext(browser_context());
75 ExtensionTestMessageListener listener("info_please", true); 75 ExtensionTestMessageListener listener("info_please", true);
76 ASSERT_TRUE(LoadApp("sockets_tcp_server/api")); 76 ASSERT_TRUE(LoadApp("sockets_tcp_server/api"));
(...skipping 11 matching lines...) Expand all
88 ASSERT_TRUE(extension); 88 ASSERT_TRUE(extension);
89 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); 89 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
90 90
91 UnloadApp(extension); 91 UnloadApp(extension);
92 92
93 ASSERT_TRUE(LoadApp(path)) << message_; 93 ASSERT_TRUE(LoadApp(path)) << message_;
94 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); 94 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
95 } 95 }
96 96
97 } // namespace extensions 97 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/api/sockets_tcp/sockets_tcp_apitest.cc ('k') | extensions/browser/api_test_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698