diff options
author | scr@chromium.org <scr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-05 04:24:20 +0000 |
---|---|---|
committer | scr@chromium.org <scr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-05 04:24:20 +0000 |
commit | 26d47586aab3b841a1ecbe7bdfcabb86f5243ff2 (patch) | |
tree | 7b90a780e71bcdd8ea5bcd4671952972e4424a0d /chrome/test/data/unit | |
parent | d15c370b5043f7959e05fe6be68599093d1554fd (diff) | |
download | chromium_src-26d47586aab3b841a1ecbe7bdfcabb86f5243ff2.zip chromium_src-26d47586aab3b841a1ecbe7bdfcabb86f5243ff2.tar.gz chromium_src-26d47586aab3b841a1ecbe7bdfcabb86f5243ff2.tar.bz2 |
Allow javascript unit tests using webui test_api framework.
I moved javascript2webui.js over to chrome/test/base/js2gtest.js and shared it
across webui and unit tests with an extra parameter for test type, which governs
the few differences, such as what to include/subclass from and the flavor of
gtest (TEST_F v. IN_PROC_BROWSER_TEST_F).
v8_unit_test implemented 2 main methods to make it work with the generated C++
- AddLibrary - loads the file in the test context
- RunJavascriptF - launches the runTest with the testFixture and testName,
coordinating with Error and ChromeSend to report results.
Helper functions:
- Error - watches for console.error, noting failure if seen.
- ChromeSend - pulls apart the result from the test_api's call to
chrome.send('testResult', [ok, msg])
R=arv@chromium.org
BUG=87820
TEST=unit_tests --gtest_filter=FrameworkUnitTest.*
Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=108391
Review URL: http://codereview.chromium.org/8418015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@108773 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/data/unit')
-rw-r--r-- | chrome/test/data/unit/framework_unittest.js | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/chrome/test/data/unit/framework_unittest.js b/chrome/test/data/unit/framework_unittest.js new file mode 100644 index 0000000..3eee034 --- /dev/null +++ b/chrome/test/data/unit/framework_unittest.js @@ -0,0 +1,42 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +/** + * Class for testing the unit_test framework. + * @constructor + */ +function FrameworkUnitTest() {} + +FrameworkUnitTest.prototype = { + __proto__: testing.Test.prototype, +}; + +TEST_F('FrameworkUnitTest', 'testExpectTrueOk', function() { + expectTrue(true); +}); + +TEST_F('FrameworkUnitTest', 'testAssertTrueOk', function() { + assertTrue(true); +}); + +/** + * Failing version of FrameworkUnitTest. + * @constructor + */ +function FrameworkUnitTestFail() {} + +FrameworkUnitTestFail.prototype = { + __proto__: FrameworkUnitTest.prototype, + + /** inheritDoc */ + testShouldFail: true, +}; + +TEST_F('FrameworkUnitTestFail', 'testExpectFailFails', function() { + expectNotReached(); +}); + +TEST_F('FrameworkUnitTestFail', 'testAssertFailFails', function() { + assertNotReached(); +});
\ No newline at end of file |