summaryrefslogtreecommitdiffstats
path: root/extensions/browser/api_test_utils.cc
diff options
context:
space:
mode:
authoryoz <yoz@chromium.org>2014-08-27 19:23:05 -0700
committerCommit bot <commit-bot@chromium.org>2014-08-28 02:23:49 +0000
commitb6272ef2f62c82478c53f93eb42f2cabed2a21d0 (patch)
tree469976dae040d570b7b8e89fa1a807c5a1b25892 /extensions/browser/api_test_utils.cc
parent6fe3f977401afbb8e62adf7912e9bd59c0445d02 (diff)
downloadchromium_src-b6272ef2f62c82478c53f93eb42f2cabed2a21d0.zip
chromium_src-b6272ef2f62c82478c53f93eb42f2cabed2a21d0.tar.gz
chromium_src-b6272ef2f62c82478c53f93eb42f2cabed2a21d0.tar.bz2
Rework ExtensionApiUnittest to run in extensions_unittests, removing its Chrome dependencies.
Move SocketsTcpUnitTest as the first test to use it. BUG=397164 Review URL: https://codereview.chromium.org/461273003 Cr-Commit-Position: refs/heads/master@{#292296}
Diffstat (limited to 'extensions/browser/api_test_utils.cc')
-rw-r--r--extensions/browser/api_test_utils.cc21
1 files changed, 21 insertions, 0 deletions
diff --git a/extensions/browser/api_test_utils.cc b/extensions/browser/api_test_utils.cc
index 1c70b27..dd04bb7 100644
--- a/extensions/browser/api_test_utils.cc
+++ b/extensions/browser/api_test_utils.cc
@@ -132,6 +132,27 @@ base::Value* RunFunctionAndReturnSingleResult(
function, args, context, dispatcher.Pass(), flags);
}
+std::string RunFunctionAndReturnError(UIThreadExtensionFunction* function,
+ const std::string& args,
+ content::BrowserContext* context) {
+ return RunFunctionAndReturnError(function, args, context, NONE);
+}
+
+std::string RunFunctionAndReturnError(UIThreadExtensionFunction* function,
+ const std::string& args,
+ content::BrowserContext* context,
+ RunFunctionFlags flags) {
+ TestFunctionDispatcherDelegate delegate;
+ scoped_ptr<ExtensionFunctionDispatcher> dispatcher(
+ new ExtensionFunctionDispatcher(context, &delegate));
+ scoped_refptr<ExtensionFunction> function_owner(function);
+ // Without a callback the function will not generate a result.
+ function->set_has_callback(true);
+ RunFunction(function, args, context, dispatcher.Pass(), flags);
+ EXPECT_FALSE(function->GetResultList()) << "Did not expect a result";
+ return function->GetError();
+}
+
bool RunFunction(UIThreadExtensionFunction* function,
const std::string& args,
content::BrowserContext* context,