OLD | NEW |
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/values.h" | 5 #include "base/values.h" |
6 #include "chrome/browser/browser_process_impl.h" | 6 #include "chrome/browser/browser_process_impl.h" |
7 #include "chrome/browser/extensions/api/api_function.h" | |
8 #include "chrome/browser/extensions/api/api_resource_manager.h" | 7 #include "chrome/browser/extensions/api/api_resource_manager.h" |
9 #include "chrome/browser/extensions/api/socket/socket.h" | 8 #include "chrome/browser/extensions/api/socket/socket.h" |
10 #include "chrome/browser/extensions/api/socket/udp_socket.h" | 9 #include "chrome/browser/extensions/api/socket/udp_socket.h" |
11 #include "chrome/browser/extensions/api/sockets_udp/sockets_udp_api.h" | 10 #include "chrome/browser/extensions/api/sockets_udp/sockets_udp_api.h" |
12 #include "chrome/browser/extensions/extension_api_unittest.h" | 11 #include "chrome/browser/extensions/extension_api_unittest.h" |
13 #include "chrome/browser/extensions/extension_function_test_utils.h" | 12 #include "chrome/browser/extensions/extension_function_test_utils.h" |
14 #include "chrome/browser/extensions/test_extension_system.h" | 13 #include "chrome/browser/extensions/test_extension_system.h" |
15 #include "chrome/browser/profiles/profile_manager.h" | 14 #include "chrome/browser/profiles/profile_manager.h" |
16 #include "chrome/test/base/testing_browser_process.h" | 15 #include "chrome/test/base/testing_browser_process.h" |
17 #include "testing/gmock/include/gmock/gmock.h" | 16 #include "testing/gmock/include/gmock/gmock.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
19 | 18 |
20 namespace utils = extension_function_test_utils; | 19 namespace utils = extension_function_test_utils; |
21 | 20 |
22 namespace extensions { | 21 namespace extensions { |
23 namespace api { | 22 namespace api { |
24 | 23 |
25 static | 24 static BrowserContextKeyedService* ApiResourceManagerTestFactory( |
26 BrowserContextKeyedService* ApiResourceManagerTestFactory( | 25 content::BrowserContext* context) { |
27 content::BrowserContext* profile) { | |
28 content::BrowserThread::ID id; | 26 content::BrowserThread::ID id; |
29 CHECK(content::BrowserThread::GetCurrentThreadIdentifier(&id)); | 27 CHECK(content::BrowserThread::GetCurrentThreadIdentifier(&id)); |
30 return ApiResourceManager<ResumableUDPSocket>:: | 28 return ApiResourceManager< |
31 CreateApiResourceManagerForTest(static_cast<Profile*>(profile), id); | 29 ResumableUDPSocket>::CreateApiResourceManagerForTest(context, id); |
32 } | 30 } |
33 | 31 |
34 class SocketsUdpUnitTest : public ExtensionApiUnittest { | 32 class SocketsUdpUnitTest : public ExtensionApiUnittest { |
35 public: | 33 public: |
36 virtual void SetUp() { | 34 virtual void SetUp() { |
37 ExtensionApiUnittest::SetUp(); | 35 ExtensionApiUnittest::SetUp(); |
38 | 36 |
39 ApiResourceManager<ResumableUDPSocket>::GetFactoryInstance()-> | 37 ApiResourceManager<ResumableUDPSocket>::GetFactoryInstance()-> |
40 SetTestingFactoryAndUse(browser()->profile(), | 38 SetTestingFactoryAndUse(browser()->profile(), |
41 ApiResourceManagerTestFactory); | 39 ApiResourceManagerTestFactory); |
(...skipping 10 matching lines...) Expand all Loading... |
52 function->set_work_thread_id(id); | 50 function->set_work_thread_id(id); |
53 | 51 |
54 // Run tests | 52 // Run tests |
55 scoped_ptr<base::DictionaryValue> result(RunFunctionAndReturnDictionary( | 53 scoped_ptr<base::DictionaryValue> result(RunFunctionAndReturnDictionary( |
56 function, "[{\"persistent\": true, \"name\": \"foo\"}]")); | 54 function, "[{\"persistent\": true, \"name\": \"foo\"}]")); |
57 ASSERT_TRUE(result.get()); | 55 ASSERT_TRUE(result.get()); |
58 } | 56 } |
59 | 57 |
60 } // namespace api | 58 } // namespace api |
61 } // namespace extensions | 59 } // namespace extensions |
OLD | NEW |