Roll src/third_party/WebKit a3b4a2e:7441784 (svn 202551:202552)
[chromium-blink-merge.git] / extensions / browser / api / sockets_udp / sockets_udp_api_unittest.cc
blobebba7bcc1a95353e88e84b2a9f3ec4119f253960
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 {
16 namespace api {
18 static scoped_ptr<KeyedService> ApiResourceManagerTestFactory(
19 content::BrowserContext* context) {
20 return make_scoped_ptr(new ApiResourceManager<ResumableUDPSocket>(context));
23 class SocketsUdpUnitTest : public ApiUnitTest {
24 public:
25 void SetUp() override {
26 ApiUnitTest::SetUp();
28 ApiResourceManager<ResumableUDPSocket>::GetFactoryInstance()
29 ->SetTestingFactoryAndUse(browser_context(),
30 ApiResourceManagerTestFactory);
34 TEST_F(SocketsUdpUnitTest, Create) {
35 // Get BrowserThread
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);
43 // Run tests
44 scoped_ptr<base::DictionaryValue> result(RunFunctionAndReturnDictionary(
45 function, "[{\"persistent\": true, \"name\": \"foo\"}]"));
46 ASSERT_TRUE(result.get());
49 } // namespace api
50 } // namespace extensions