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
3 // found in the LICENSE file.
5 #include "base/memory/scoped_ptr.h"
6 #include "base/values.h"
7 #include "extensions/browser/api/api_resource_manager.h"
8 #include "extensions/browser/api/socket/socket.h"
9 #include "extensions/browser/api/socket/udp_socket.h"
10 #include "extensions/browser/api/sockets_udp/sockets_udp_api.h"
11 #include "extensions/browser/api_unittest.h"
12 #include "testing/gmock/include/gmock/gmock.h"
13 #include "testing/gtest/include/gtest/gtest.h"
15 namespace extensions
{
18 static scoped_ptr
<KeyedService
> ApiResourceManagerTestFactory(
19 content::BrowserContext
* context
) {
20 return make_scoped_ptr(new ApiResourceManager
<ResumableUDPSocket
>(context
));
23 class SocketsUdpUnitTest
: public ApiUnitTest
{
25 void SetUp() override
{
28 ApiResourceManager
<ResumableUDPSocket
>::GetFactoryInstance()
29 ->SetTestingFactoryAndUse(browser_context(),
30 ApiResourceManagerTestFactory
);
34 TEST_F(SocketsUdpUnitTest
, Create
) {
36 content::BrowserThread::ID id
;
37 CHECK(content::BrowserThread::GetCurrentThreadIdentifier(&id
));
39 // Create SocketCreateFunction and put it on BrowserThread
40 SocketsUdpCreateFunction
* function
= new SocketsUdpCreateFunction();
41 function
->set_work_thread_id(id
);
44 scoped_ptr
<base::DictionaryValue
> result(RunFunctionAndReturnDictionary(
45 function
, "[{\"persistent\": true, \"name\": \"foo\"}]"));
46 ASSERT_TRUE(result
.get());
50 } // namespace extensions