summaryrefslogtreecommitdiffstats
path: root/gin/converter.cc
diff options
context:
space:
mode:
authorabarth@chromium.org <abarth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-25 21:26:15 +0000
committerabarth@chromium.org <abarth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-25 21:26:15 +0000
commit2f70342531d0cb7335ea88ec5579d0a8a8bb114f (patch)
treebf1883a26ccf8493b5419fb239190619c249481b /gin/converter.cc
parentae6f06153630c4c0940a4630443ae4faf44ef409 (diff)
downloadchromium_src-2f70342531d0cb7335ea88ec5579d0a8a8bb114f.zip
chromium_src-2f70342531d0cb7335ea88ec5579d0a8a8bb114f.tar.gz
chromium_src-2f70342531d0cb7335ea88ec5579d0a8a8bb114f.tar.bz2
[Gin] Add a basic unit testing framework
Previously, we were using JavaScript bindings to gtest to unit test JavaScript code in Gin and Mojo. The gtest bindings were very basic and not very idiomatic. This CL introduces a simple AMD module call "expect" to help us write more idiomatic unit tests. The API for "expect" is based on the popular Jasmine unit testing framework for node.js. I investigated just importing one of Node's many unit testing frameworks, but they all try to do too much (e.g., drive the entire test harness via Node's file system interface). The "expect" modules doesn't try to drive the testing process. We just let gtest handle that. Instead, "expect" just provides a simple language in which to write test assertions. We'll likely evolve our testing strategy over time, but hopefully this CL is an improvement over the primitive gtest bindings. R=jochen@chromium.org TBR=joth@chromium.org BUG=none Review URL: https://codereview.chromium.org/85223002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@237145 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gin/converter.cc')
-rw-r--r--gin/converter.cc8
1 files changed, 8 insertions, 0 deletions
diff --git a/gin/converter.cc b/gin/converter.cc
index e60e3a0..614e515 100644
--- a/gin/converter.cc
+++ b/gin/converter.cc
@@ -171,5 +171,13 @@ v8::Handle<v8::String> StringToSymbol(v8::Isolate* isolate,
static_cast<uint32_t>(val.length()));
}
+std::string V8ToString(v8::Handle<v8::Value> value) {
+ if (value.IsEmpty())
+ return std::string();
+ std::string result;
+ if (!ConvertFromV8(value, &result))
+ return std::string();
+ return result;
+}
} // namespace gin