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

Side by Side Diff: extensions/browser/api/sockets_tcp/sockets_tcp_api_unittest.cc

Issue 461273003: Rework ExtensionApiUnittest to run in extensions_unittests, removing its Chrome dependencies. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: content_plugin Created 6 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 | Annotate | Revision Log
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/values.h" 5 #include "base/values.h"
6 #include "chrome/browser/browser_process_impl.h" 6 #include "content/public/test/test_browser_context.h"
7 #include "chrome/browser/extensions/extension_api_unittest.h"
8 #include "chrome/browser/extensions/test_extension_system.h"
9 #include "chrome/browser/profiles/profile_manager.h"
10 #include "chrome/test/base/testing_browser_process.h"
11 #include "extensions/browser/api/api_resource_manager.h" 7 #include "extensions/browser/api/api_resource_manager.h"
12 #include "extensions/browser/api/socket/socket.h" 8 #include "extensions/browser/api/socket/socket.h"
13 #include "extensions/browser/api/socket/tcp_socket.h" 9 #include "extensions/browser/api/socket/tcp_socket.h"
14 #include "extensions/browser/api/sockets_tcp/sockets_tcp_api.h" 10 #include "extensions/browser/api/sockets_tcp/sockets_tcp_api.h"
11 #include "extensions/browser/api_unittest.h"
15 #include "testing/gmock/include/gmock/gmock.h" 12 #include "testing/gmock/include/gmock/gmock.h"
16 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
17 14
18 namespace extensions { 15 namespace extensions {
19 namespace core_api { 16 namespace core_api {
20 17
21 static KeyedService* ApiResourceManagerTestFactory( 18 static KeyedService* ApiResourceManagerTestFactory(
22 content::BrowserContext* context) { 19 content::BrowserContext* context) {
23 content::BrowserThread::ID id; 20 content::BrowserThread::ID id;
24 CHECK(content::BrowserThread::GetCurrentThreadIdentifier(&id)); 21 CHECK(content::BrowserThread::GetCurrentThreadIdentifier(&id));
25 return ApiResourceManager< 22 return ApiResourceManager<
26 ResumableTCPSocket>::CreateApiResourceManagerForTest(context, id); 23 ResumableTCPSocket>::CreateApiResourceManagerForTest(context, id);
27 } 24 }
28 25
29 class SocketsTcpUnitTest : public ExtensionApiUnittest { 26 class SocketsTcpUnitTest : public ApiUnitTest {
30 public: 27 public:
31 virtual void SetUp() { 28 virtual void SetUp() {
32 ExtensionApiUnittest::SetUp(); 29 ApiUnitTest::SetUp();
33 30
34 ApiResourceManager<ResumableTCPSocket>::GetFactoryInstance() 31 ApiResourceManager<ResumableTCPSocket>::GetFactoryInstance()
35 ->SetTestingFactoryAndUse(browser()->profile(), 32 ->SetTestingFactoryAndUse(browser_context(),
36 ApiResourceManagerTestFactory); 33 ApiResourceManagerTestFactory);
37 } 34 }
38 }; 35 };
39 36
40 TEST_F(SocketsTcpUnitTest, Create) { 37 TEST_F(SocketsTcpUnitTest, Create) {
41 // Get BrowserThread 38 // Get BrowserThread
42 content::BrowserThread::ID id; 39 content::BrowserThread::ID id;
43 CHECK(content::BrowserThread::GetCurrentThreadIdentifier(&id)); 40 CHECK(content::BrowserThread::GetCurrentThreadIdentifier(&id));
44 41
45 // Create SocketCreateFunction and put it on BrowserThread 42 // Create SocketCreateFunction and put it on BrowserThread
46 SocketsTcpCreateFunction* function = new SocketsTcpCreateFunction(); 43 SocketsTcpCreateFunction* function = new SocketsTcpCreateFunction();
47 function->set_work_thread_id(id); 44 function->set_work_thread_id(id);
48 45
49 // Run tests 46 // Run tests
50 scoped_ptr<base::DictionaryValue> result(RunFunctionAndReturnDictionary( 47 scoped_ptr<base::DictionaryValue> result(RunFunctionAndReturnDictionary(
51 function, "[{\"persistent\": true, \"name\": \"foo\"}]")); 48 function, "[{\"persistent\": true, \"name\": \"foo\"}]"));
52 ASSERT_TRUE(result.get()); 49 ASSERT_TRUE(result.get());
53 } 50 }
54 51
55 } // namespace core_api 52 } // namespace core_api
56 } // namespace extensions 53 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698