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

Unified Diff: extensions/renderer/api_binding_test_util.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.h ('k') | extensions/renderer/api_bindings_system_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/renderer/api_binding_test_util.cc
diff --git a/extensions/renderer/api_binding_test_util.cc b/extensions/renderer/api_binding_test_util.cc
index d1b0cc80b59a04dc5619f9c21f2f205362aba3f8..57fa7afbd21686952944ced122b543ad3772d97b 100644
--- a/extensions/renderer/api_binding_test_util.cc
+++ b/extensions/renderer/api_binding_test_util.cc
@@ -175,4 +175,21 @@ std::unique_ptr<base::Value> GetBaseValuePropertyFromObject(
return V8ToBaseValue(GetPropertyFromObject(object, context, key), context);
}
+std::string GetStringPropertyFromObject(v8::Local<v8::Object> object,
+ v8::Local<v8::Context> context,
+ base::StringPiece key) {
+ v8::Local<v8::Value> v8_val = GetPropertyFromObject(object, context, key);
+ if (v8_val.IsEmpty())
+ return "empty";
+ if (v8_val->IsNull())
+ return "null";
+ if (v8_val->IsUndefined())
+ return "undefined";
+ if (v8_val->IsFunction())
+ return "function";
+ std::unique_ptr<base::Value> json_prop = V8ToBaseValue(v8_val, context);
+ DCHECK(json_prop) << key;
+ return ValueToString(*json_prop);
+}
+
} // namespace extensions
« no previous file with comments | « extensions/renderer/api_binding_test_util.h ('k') | extensions/renderer/api_bindings_system_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698