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

Unified Diff: extensions/renderer/api_bindings_system_unittest.cc

Issue 2601143002: [Extensions Bindings] Add a GetStringPropertyFromObject test method (Closed)
Patch Set: Created 4 years 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_test_util.cc ('k') | extensions/renderer/api_event_handler_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/renderer/api_bindings_system_unittest.cc
diff --git a/extensions/renderer/api_bindings_system_unittest.cc b/extensions/renderer/api_bindings_system_unittest.cc
index 6586038795caf08f9f40dc5835c7c507297f80f8..214f2f66a08e733063b422d4799475081d062e35 100644
--- a/extensions/renderer/api_bindings_system_unittest.cc
+++ b/extensions/renderer/api_bindings_system_unittest.cc
@@ -232,10 +232,9 @@ TEST_F(APIBindingsSystemTest, TestInitializationAndCallbacks) {
bindings_system()->CompleteRequest(last_request()->request_id,
*expected_args);
- std::unique_ptr<base::Value> result = GetBaseValuePropertyFromObject(
- context->Global(), context, "callbackArguments");
- ASSERT_TRUE(result);
- EXPECT_EQ(ReplaceSingleQuotes(kResponseArgsJson), ValueToString(*result));
+ EXPECT_EQ(ReplaceSingleQuotes(kResponseArgsJson),
+ GetStringPropertyFromObject(context->Global(), context,
+ "callbackArguments"));
reset_last_request();
}
@@ -255,10 +254,8 @@ TEST_F(APIBindingsSystemTest, TestInitializationAndCallbacks) {
bindings_system()->CompleteRequest(last_request()->request_id,
base::ListValue());
- std::unique_ptr<base::Value> result = GetBaseValuePropertyFromObject(
- context->Global(), context, "callbackArguments");
- ASSERT_TRUE(result);
- EXPECT_EQ("[]", ValueToString(*result));
+ EXPECT_EQ("[]", GetStringPropertyFromObject(context->Global(), context,
+ "callbackArguments"));
reset_last_request();
}
@@ -276,10 +273,9 @@ TEST_F(APIBindingsSystemTest, TestInitializationAndCallbacks) {
bindings_system()->FireEventInContext("alpha.alphaEvent", context,
*expected_args);
- std::unique_ptr<base::Value> result = GetBaseValuePropertyFromObject(
- context->Global(), context, "eventArguments");
- ASSERT_TRUE(result);
- EXPECT_EQ(ReplaceSingleQuotes(kResponseArgsJson), ValueToString(*result));
+ EXPECT_EQ(ReplaceSingleQuotes(kResponseArgsJson),
+ GetStringPropertyFromObject(context->Global(), context,
+ "eventArguments"));
}
{
@@ -339,10 +335,9 @@ TEST_F(APIBindingsSystemTest, TestCustomHooks) {
CallFunctionOnObject(context, alpha_api, kTestCall);
EXPECT_TRUE(did_call);
- std::unique_ptr<base::Value> result = GetBaseValuePropertyFromObject(
- context->Global(), context, "callbackArguments");
- ASSERT_TRUE(result);
- EXPECT_EQ("[\"bar\"]", ValueToString(*result));
+ EXPECT_EQ("[\"bar\"]",
+ GetStringPropertyFromObject(context->Global(), context,
+ "callbackArguments"));
}
}
@@ -485,16 +480,13 @@ TEST_F(APIBindingsSystemTestWithRealAPI, RealAPIs) {
" this.idleState = state;\n"
"});\n";
ExecuteScript(context, kTestCall);
- v8::Local<v8::Value> v8_result =
- GetPropertyFromObject(context->Global(), context, "idleState");
- EXPECT_TRUE(v8_result->IsUndefined());
+ EXPECT_EQ("undefined", GetStringPropertyFromObject(context->Global(),
+ context, "idleState"));
bindings_system()->FireEventInContext("idle.onStateChanged", context,
*ListValueFromString("['active']"));
- std::unique_ptr<base::Value> result =
- GetBaseValuePropertyFromObject(context->Global(), context, "idleState");
- ASSERT_TRUE(result);
- EXPECT_EQ("\"active\"", ValueToString(*result));
+ EXPECT_EQ("\"active\"", GetStringPropertyFromObject(context->Global(),
+ context, "idleState"));
}
}
« no previous file with comments | « extensions/renderer/api_binding_test_util.cc ('k') | extensions/renderer/api_event_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698