Unregister from GCM when the only GCM app is removed
[chromium-blink-merge.git] / extensions / browser / api / sockets_udp / sockets_udp_api_unittest.cc
blob7fbc871ad9a67d1fed394b6db5cbdc92b5ecb1b4
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/values.h"
6 #include "extensions/browser/api/api_resource_manager.h"
7 #include "extensions/browser/api/socket/socket.h"
8 #include "extensions/browser/api/socket/udp_socket.h"
9 #include "extensions/browser/api/sockets_udp/sockets_udp_api.h"
10 #include "extensions/browser/api_unittest.h"
11 #include "testing/gmock/include/gmock/gmock.h"
12 #include "testing/gtest/include/gtest/gtest.h"
14 namespace extensions {
15 namespace core_api {
17 static KeyedService* ApiResourceManagerTestFactory(
18 content::BrowserContext* context) {
19 content::BrowserThread::ID id;
20 CHECK(content::BrowserThread::GetCurrentThreadIdentifier(&id));
21 return ApiResourceManager<
22 ResumableUDPSocket>::CreateApiResourceManagerForTest(context, id);
25 class SocketsUdpUnitTest : public ApiUnitTest {
26 public:
27 void SetUp() override {
28 ApiUnitTest::SetUp();
30 ApiResourceManager<ResumableUDPSocket>::GetFactoryInstance()
31 ->SetTestingFactoryAndUse(browser_context(),
32 ApiResourceManagerTestFactory);
36 TEST_F(SocketsUdpUnitTest, Create) {
37 // Get BrowserThread
38 content::BrowserThread::ID id;
39 CHECK(content::BrowserThread::GetCurrentThreadIdentifier(&id));
41 // Create SocketCreateFunction and put it on BrowserThread
42 SocketsUdpCreateFunction* function = new SocketsUdpCreateFunction();
43 function->set_work_thread_id(id);
45 // Run tests
46 scoped_ptr<base::DictionaryValue> result(RunFunctionAndReturnDictionary(
47 function, "[{\"persistent\": true, \"name\": \"foo\"}]"));
48 ASSERT_TRUE(result.get());
51 } // namespace core_api
52 } // namespace extensions