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

Unified Diff: chrome/test/data/webui/mock4js_browsertest.js

Issue 8515016: WebUI test framework: fix Mock4JS verification, allow chrome.send passthrough. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 9 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 | « chrome/test/data/webui/chrome_send_browsertest.js ('k') | chrome/test/data/webui/test_api.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/data/webui/mock4js_browsertest.js
diff --git a/chrome/test/data/webui/mock4js_browsertest.js b/chrome/test/data/webui/mock4js_browsertest.js
new file mode 100644
index 0000000000000000000000000000000000000000..1fd0cfe883cac76c8715d6e0edf9c80114f7cff6
--- /dev/null
+++ b/chrome/test/data/webui/mock4js_browsertest.js
@@ -0,0 +1,76 @@
+// 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.
+
+/**
+ * @fileoverview Tests for Mock4JS to ensure that expectations pass or fail as
+ * expected using the test framework.
+ * @author scr@chromium.org (Sheridan Rawlins)
+ * @see test_api.js
+ */
+
+/**
+ * Test fixture for Mock4JS testing.
+ * @constructor
+ * @extends {testing.Test}
+ */
+function Mock4JSWebUITest() {}
+
+Mock4JSWebUITest.prototype = {
+ __proto__: testing.Test.prototype,
+
+ /** @inheritDoc */
+ browsePreload: DUMMY_URL,
+
+ /** @inheritDoc */
+ setUp: function() {
+ function MockHandler() {}
+ MockHandler.prototype = {
+ callMe: function() {},
+ };
+ this.mockHandler = mock(MockHandler);
+ },
+};
+
+TEST_F('Mock4JSWebUITest', 'CalledExpectPasses', function() {
+ this.mockHandler.expects(once()).callMe();
+ this.mockHandler.proxy().callMe();
+});
+
+TEST_F('Mock4JSWebUITest', 'CalledTwiceExpectTwice', function() {
+ this.mockHandler.expects(exactly(2)).callMe();
+ var proxy = this.mockHandler.proxy();
+ proxy.callMe();
+ proxy.callMe();
+});
+
+/**
+ * Test fixture for Mock4JS testing which is expected to fail.
+ * @constructor
+ * @extends {Mock4JSWebUITest}
+ */
+function Mock4JSWebUITestFails() {}
+
+Mock4JSWebUITestFails.prototype = {
+ __proto__: Mock4JSWebUITest.prototype,
+
+ /** @inheritDoc */
+ testShouldFail: true,
+};
+
+TEST_F('Mock4JSWebUITestFails', 'NotCalledExpectFails', function() {
+ this.mockHandler.expects(once()).callMe();
+});
+
+TEST_F('Mock4JSWebUITestFails', 'CalledTwiceExpectOnceFails', function() {
+ this.mockHandler.expects(once()).callMe();
+ var proxy = this.mockHandler.proxy();
+ proxy.callMe();
+ proxy.callMe();
+});
+
+TEST_F('Mock4JSWebUITestFails', 'CalledOnceExpectTwiceFails', function() {
+ this.mockHandler.expects(exactly(2)).callMe();
+ var proxy = this.mockHandler.proxy();
+ proxy.callMe();
+});
« no previous file with comments | « chrome/test/data/webui/chrome_send_browsertest.js ('k') | chrome/test/data/webui/test_api.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698