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

Unified Diff: extensions/renderer/api_binding_unittest.cc

Issue 2438623002: [Extensions Bindings] Add APIBindingsSystem (Closed)
Patch Set: lazyboy's Created 4 years, 1 month 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
« no previous file with comments | « extensions/renderer/api_binding.cc ('k') | extensions/renderer/api_bindings_system.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/renderer/api_binding_unittest.cc
diff --git a/extensions/renderer/api_binding_unittest.cc b/extensions/renderer/api_binding_unittest.cc
index e7dbda2d666d971b054d0de43c57b8fa0bbe9eaa..1a47125a539690405f31880483351512ec7b2846 100644
--- a/extensions/renderer/api_binding_unittest.cc
+++ b/extensions/renderer/api_binding_unittest.cc
@@ -198,7 +198,7 @@ TEST_F(APIBindingTest, Test) {
ASSERT_TRUE(functions);
ArgumentSpec::RefMap refs;
APIBinding binding(
- "test", *functions, base::ListValue(),
+ "test", *functions, nullptr,
base::Bind(&APIBindingTest::OnFunctionCall, base::Unretained(this)),
&refs);
EXPECT_TRUE(refs.empty());
@@ -300,7 +300,7 @@ TEST_F(APIBindingTest, TypeRefsTest) {
ASSERT_TRUE(types);
ArgumentSpec::RefMap refs;
APIBinding binding(
- "test", *functions, *types,
+ "test", *functions, types.get(),
base::Bind(&APIBindingTest::OnFunctionCall, base::Unretained(this)),
&refs);
EXPECT_EQ(2u, refs.size());
@@ -327,58 +327,4 @@ TEST_F(APIBindingTest, TypeRefsTest) {
ExpectFailure(binding_object, "obj.takesRefEnum('gamma')", kError);
}
-// TODO(devlin): Once we have an object that encompasses all these pieces (the
-// APIBinding, ArgumentSpec::RefMap, and APIRequestHandler), we should move this
-// test.
-TEST_F(APIBindingTest, Callbacks) {
- const char kTestCall[] =
- "obj.functionWithCallback('foo', function() {\n"
- " this.callbackArguments = Array.from(arguments);\n"
- "});";
-
- const char kFunctionSpec[] =
- "[{"
- " 'name': 'functionWithCallback',"
- " 'parameters': [{"
- " 'name': 'str',"
- " 'type': 'string'"
- " }, {"
- " 'name': 'callback',"
- " 'type': 'function'"
- " }]"
- "}]";
-
- std::unique_ptr<base::ListValue> functions =
- ListValueFromString(kFunctionSpec);
- ASSERT_TRUE(functions);
- ArgumentSpec::RefMap refs;
- APIBinding binding(
- "test", *functions, base::ListValue(),
- base::Bind(&APIBindingTest::OnFunctionCall, base::Unretained(this)),
- &refs);
-
- v8::Isolate* isolate = instance_->isolate();
-
- v8::HandleScope handle_scope(isolate);
- v8::Local<v8::Context> context =
- v8::Local<v8::Context>::New(isolate, context_);
-
- v8::Local<v8::Object> binding_object =
- binding.CreateInstance(context, isolate);
-
- ExpectPass(binding_object, kTestCall, "['foo']");
- ASSERT_FALSE(last_request_id().empty());
- const char kResponseArgsJson[] = "['response',1,{'key':42}]";
- std::unique_ptr<base::ListValue> expected_args =
- ListValueFromString(kResponseArgsJson);
- request_handler()->CompleteRequest(last_request_id(), *expected_args);
-
- v8::Local<v8::Value> res =
- GetPropertyFromObject(context->Global(), context, "callbackArguments");
-
- std::unique_ptr<base::Value> out_val = V8ToBaseValue(res, context);
- ASSERT_TRUE(out_val);
- EXPECT_EQ(ReplaceSingleQuotes(kResponseArgsJson), ValueToString(*out_val));
-}
-
} // namespace extensions
« no previous file with comments | « extensions/renderer/api_binding.cc ('k') | extensions/renderer/api_bindings_system.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698