summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/api/sockets_tcp_server
diff options
context:
space:
mode:
authorrdevlin.cronin@chromium.org <rdevlin.cronin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-27 22:15:20 +0000
committerrdevlin.cronin@chromium.org <rdevlin.cronin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-27 22:15:20 +0000
commit628c93f00246fb0909594d6cf7f5400065c54e91 (patch)
treed3f5198b8974eca332a4af12577563808e02439e /chrome/browser/extensions/api/sockets_tcp_server
parent3b8cf7f403950054b3e8d4398146ce4b8854f36b (diff)
downloadchromium_src-628c93f00246fb0909594d6cf7f5400065c54e91.zip
chromium_src-628c93f00246fb0909594d6cf7f5400065c54e91.tar.gz
chromium_src-628c93f00246fb0909594d6cf7f5400065c54e91.tar.bz2
Make an ExtensionApiUnittest class for running API functions
Several different test files are using the same code for running api functions in a unit test, but they aren't sharing code. Fix this. Review URL: https://codereview.chromium.org/131973017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@247315 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/api/sockets_tcp_server')
-rw-r--r--chrome/browser/extensions/api/sockets_tcp_server/sockets_tcp_server_api_unittest.cc30
1 files changed, 4 insertions, 26 deletions
diff --git a/chrome/browser/extensions/api/sockets_tcp_server/sockets_tcp_server_api_unittest.cc b/chrome/browser/extensions/api/sockets_tcp_server/sockets_tcp_server_api_unittest.cc
index 6ed0f9e..b81f41a 100644
--- a/chrome/browser/extensions/api/sockets_tcp_server/sockets_tcp_server_api_unittest.cc
+++ b/chrome/browser/extensions/api/sockets_tcp_server/sockets_tcp_server_api_unittest.cc
@@ -9,16 +9,13 @@
#include "chrome/browser/extensions/api/socket/socket.h"
#include "chrome/browser/extensions/api/socket/tcp_socket.h"
#include "chrome/browser/extensions/api/sockets_tcp_server/sockets_tcp_server_api.h"
-#include "chrome/browser/extensions/extension_function_test_utils.h"
+#include "chrome/browser/extensions/extension_api_unittest.h"
#include "chrome/browser/extensions/test_extension_system.h"
#include "chrome/browser/profiles/profile_manager.h"
-#include "chrome/test/base/browser_with_test_window_test.h"
#include "chrome/test/base/testing_browser_process.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
-namespace utils = extension_function_test_utils;
-
namespace extensions {
namespace api {
@@ -40,10 +37,10 @@ BrowserContextKeyedService* ApiResourceManagerTestServerFactory(
CreateApiResourceManagerForTest(static_cast<Profile*>(profile), id);
}
-class SocketsTcpServerUnitTest : public BrowserWithTestWindowTest {
+class SocketsTcpServerUnitTest : public ExtensionApiUnittest {
public:
virtual void SetUp() {
- BrowserWithTestWindowTest::SetUp();
+ ExtensionApiUnittest::SetUp();
ApiResourceManager<ResumableTCPSocket>::GetFactoryInstance()->
SetTestingFactoryAndUse(browser()->profile(),
@@ -52,26 +49,7 @@ class SocketsTcpServerUnitTest : public BrowserWithTestWindowTest {
ApiResourceManager<ResumableTCPServerSocket>::GetFactoryInstance()->
SetTestingFactoryAndUse(browser()->profile(),
ApiResourceManagerTestServerFactory);
-
- extension_ = utils::CreateEmptyExtensionWithLocation(
- extensions::Manifest::UNPACKED);
- }
-
- base::Value* RunFunctionWithExtension(
- UIThreadExtensionFunction* function, const std::string& args) {
- scoped_refptr<UIThreadExtensionFunction> delete_function(function);
- function->set_extension(extension_.get());
- return utils::RunFunctionAndReturnSingleResult(function, args, browser());
}
-
- base::DictionaryValue* RunFunctionAndReturnDict(
- UIThreadExtensionFunction* function, const std::string& args) {
- base::Value* result = RunFunctionWithExtension(function, args);
- return result ? utils::ToDictionary(result) : NULL;
- }
-
- protected:
- scoped_refptr<extensions::Extension> extension_;
};
TEST_F(SocketsTcpServerUnitTest, Create) {
@@ -85,7 +63,7 @@ TEST_F(SocketsTcpServerUnitTest, Create) {
function->set_work_thread_id(id);
// Run tests
- scoped_ptr<base::DictionaryValue> result(RunFunctionAndReturnDict(
+ scoped_ptr<base::DictionaryValue> result(RunFunctionAndReturnDictionary(
function, "[{\"persistent\": true, \"name\": \"foo\"}]"));
ASSERT_TRUE(result.get());
}