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

Unified Diff: chrome/browser/extensions/extension_function_test_utils.cc

Issue 394103004: Move DnsApiTest.DnsResolveIPLiteral and DnsApiTest.DnsResolveHostname to app_shell_browsertests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_function_test_utils.cc
diff --git a/chrome/browser/extensions/extension_function_test_utils.cc b/chrome/browser/extensions/extension_function_test_utils.cc
index 94951caac12dcd283f461ce67201d777abf1f630..689a58d649bafaaaa4a8c54ea1437ae3d97b8737 100644
--- a/chrome/browser/extensions/extension_function_test_utils.cc
+++ b/chrome/browser/extensions/extension_function_test_utils.cc
@@ -13,6 +13,7 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/test/base/ui_test_utils.h"
+#include "extensions/browser/api_test_utils.h"
#include "extensions/browser/extension_function.h"
#include "extensions/browser/extension_function_dispatcher.h"
#include "extensions/common/extension.h"
@@ -55,11 +56,10 @@ base::Value* ParseJSON(const std::string& data) {
}
base::ListValue* ParseList(const std::string& data) {
- scoped_ptr<base::Value> result(ParseJSON(data));
- if (result.get() && result->IsType(base::Value::TYPE_LIST))
- return static_cast<base::ListValue*>(result.release());
- else
- return NULL;
+ base::Value* result(ParseJSON(data));
James Cook 2014/07/18 20:32:48 nit: I find "result = ParseJSON(data)" slightly ea
Yoyo Zhou 2014/07/22 00:10:31 Me too.
+ base::ListValue* list = NULL;
+ result->GetAsList(&list);
+ return list;
}
base::DictionaryValue* ParseDictionary(
@@ -243,31 +243,18 @@ bool RunFunction(UIThreadExtensionFunction* function,
const std::string& args,
Browser* browser,
RunFunctionFlags flags) {
- SendResponseDelegate response_delegate;
- function->set_test_delegate(&response_delegate);
- scoped_ptr<base::ListValue> parsed_args(ParseList(args));
- EXPECT_TRUE(parsed_args.get()) <<
- "Could not parse extension function arguments: " << args;
- function->SetArgs(parsed_args.get());
-
TestFunctionDispatcherDelegate dispatcher_delegate(browser);
- extensions::ExtensionFunctionDispatcher dispatcher(browser->profile(),
- &dispatcher_delegate);
- function->set_dispatcher(dispatcher.AsWeakPtr());
-
- function->set_browser_context(browser->profile());
- function->set_include_incognito(flags & INCLUDE_INCOGNITO);
- function->Run()->Execute();
-
- // If the RunAsync of |function| didn't already call SendResponse, run the
- // message loop until they do.
- if (!response_delegate.HasResponse()) {
- response_delegate.set_should_post_quit(true);
- content::RunMessageLoop();
- }
-
- EXPECT_TRUE(response_delegate.HasResponse());
- return response_delegate.GetResponse();
+ scoped_ptr<extensions::ExtensionFunctionDispatcher> dispatcher(
+ new extensions::ExtensionFunctionDispatcher(browser->profile(),
+ &dispatcher_delegate));
+ // The cast is a hack; these flags should be defined in only one place.
James Cook 2014/07/18 20:32:48 TODO(yoz) here
Yoyo Zhou 2014/07/22 00:10:31 added
+ // See crbug.com/394840.
+ return extensions::api_test_utils::RunFunction(
+ function,
+ args,
+ browser->profile(),
+ dispatcher.Pass(),
+ static_cast<extensions::api_test_utils::RunFunctionFlags>(flags));
}
} // namespace extension_function_test_utils

Powered by Google App Engine
This is Rietveld 408576698