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

Side by Side Diff: chrome/test/data/webui/test_api.js

Issue 23477006: Unit tests for utility.js (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: robliao@ comments Created 7 years, 3 months 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @fileoverview Library providing basic test framework functionality. 6 * @fileoverview Library providing basic test framework functionality.
7 */ 7 */
8 8
9 /** 9 /**
10 * Namespace for |Test|. 10 * Namespace for |Test|.
(...skipping 1649 matching lines...) Expand 10 before | Expand all | Expand 10 after
1660 1660
1661 /** 1661 /**
1662 * Builds a MatchJSON agrument matcher for a given expected value. 1662 * Builds a MatchJSON agrument matcher for a given expected value.
1663 * @param {Object} expectedValue Expected value. 1663 * @param {Object} expectedValue Expected value.
1664 * @return {MatchJSON} Resulting Mock4JS matcher. 1664 * @return {MatchJSON} Resulting Mock4JS matcher.
1665 */ 1665 */
1666 function eqJSON(expectedValue) { 1666 function eqJSON(expectedValue) {
1667 return new MatchJSON(expectedValue); 1667 return new MatchJSON(expectedValue);
1668 } 1668 }
1669 1669
1670 /**
1671 * Mock4JS matcher object that matches the actual agrument and the expected
1672 * value iff the string representation of the actual argument is equal to the
1673 * expected value.
1674 * @param {string} expectedValue Expected value.
1675 * @constructor
1676 */
1677 function MatchToString(expectedValue) {
1678 this.expectedValue_ = expectedValue;
1679 }
1680
1681 MatchToString.prototype = {
1682 /**
1683 * Checks that the string representation of the actual argument, and the
skare_ 2013/08/29 00:26:14 nit: no comma before 'and'
vadimt 2013/08/29 00:35:32 I did this to avoid this interpretation: the strin
skare_ 2013/08/29 00:48:09 sort of, but I'm not witholding an lg over it or a
vadimt 2013/08/29 18:03:43 Done.
1684 * expected value are same.
skare_ 2013/08/29 00:48:09 though if not changing the above, s/are same/are t
vadimt 2013/08/29 18:03:43 Done.
1685 * @param {Object} actualArgument The argument to match.
1686 * @return {boolean} Result of the comparison.
1687 */
1688 argumentMatches: function(actualArgument) {
1689 return this.expectedValue_ === actualArgument.toString();
1690 },
1691
1692 /**
1693 * Describes the matcher.
1694 * @return {string} Description of this Mock4JS matcher.
1695 */
1696 describe: function() {
1697 return 'eqToString("' + this.expectedValue_ + '")';
1698 },
1699 };
1700
1701 /**
1702 * Builds a MatchToString agrument matcher for a given expected value.
1703 * @param {Object} expectedValue Expected value.
1704 * @return {MatchToString} Resulting Mock4JS matcher.
1705 */
1706 function eqToString(expectedValue) {
1707 return new MatchToString(expectedValue);
1708 }
1709
1670 // Exports. 1710 // Exports.
1671 testing.Test = Test; 1711 testing.Test = Test;
1672 exports.testDone = testDone; 1712 exports.testDone = testDone;
1673 exports.assertTrue = assertTrue; 1713 exports.assertTrue = assertTrue;
1674 exports.assertFalse = assertFalse; 1714 exports.assertFalse = assertFalse;
1675 exports.assertGE = assertGE; 1715 exports.assertGE = assertGE;
1676 exports.assertGT = assertGT; 1716 exports.assertGT = assertGT;
1677 exports.assertEquals = assertEquals; 1717 exports.assertEquals = assertEquals;
1678 exports.assertLE = assertLE; 1718 exports.assertLE = assertLE;
1679 exports.assertLT = assertLT; 1719 exports.assertLT = assertLT;
1680 exports.assertNotEquals = assertNotEquals; 1720 exports.assertNotEquals = assertNotEquals;
1681 exports.assertNotReached = assertNotReached; 1721 exports.assertNotReached = assertNotReached;
1682 exports.assertAccessibilityOk = assertAccessibilityOk; 1722 exports.assertAccessibilityOk = assertAccessibilityOk;
1683 exports.callFunction = callFunction; 1723 exports.callFunction = callFunction;
1684 exports.callFunctionWithSavedArgs = callFunctionWithSavedArgs; 1724 exports.callFunctionWithSavedArgs = callFunctionWithSavedArgs;
1685 exports.callGlobalWithSavedArgs = callGlobalWithSavedArgs; 1725 exports.callGlobalWithSavedArgs = callGlobalWithSavedArgs;
1686 exports.eqJSON = eqJSON; 1726 exports.eqJSON = eqJSON;
1727 exports.eqToString = eqToString;
1687 exports.expectTrue = createExpect(assertTrue); 1728 exports.expectTrue = createExpect(assertTrue);
1688 exports.expectFalse = createExpect(assertFalse); 1729 exports.expectFalse = createExpect(assertFalse);
1689 exports.expectGE = createExpect(assertGE); 1730 exports.expectGE = createExpect(assertGE);
1690 exports.expectGT = createExpect(assertGT); 1731 exports.expectGT = createExpect(assertGT);
1691 exports.expectEquals = createExpect(assertEquals); 1732 exports.expectEquals = createExpect(assertEquals);
1692 exports.expectLE = createExpect(assertLE); 1733 exports.expectLE = createExpect(assertLE);
1693 exports.expectLT = createExpect(assertLT); 1734 exports.expectLT = createExpect(assertLT);
1694 exports.expectNotEquals = createExpect(assertNotEquals); 1735 exports.expectNotEquals = createExpect(assertNotEquals);
1695 exports.expectNotReached = createExpect(assertNotReached); 1736 exports.expectNotReached = createExpect(assertNotReached);
1696 exports.expectAccessibilityOk = createExpect(assertAccessibilityOk); 1737 exports.expectAccessibilityOk = createExpect(assertAccessibilityOk);
(...skipping 13 matching lines...) Expand all
1710 exports.TEST = TEST; 1751 exports.TEST = TEST;
1711 exports.TEST_F = TEST_F; 1752 exports.TEST_F = TEST_F;
1712 exports.RUNTIME_TEST_F = TEST_F; 1753 exports.RUNTIME_TEST_F = TEST_F;
1713 exports.GEN = GEN; 1754 exports.GEN = GEN;
1714 exports.GEN_INCLUDE = GEN_INCLUDE; 1755 exports.GEN_INCLUDE = GEN_INCLUDE;
1715 exports.WhenTestDone = WhenTestDone; 1756 exports.WhenTestDone = WhenTestDone;
1716 1757
1717 // Import the Mock4JS helpers. 1758 // Import the Mock4JS helpers.
1718 Mock4JS.addMockSupport(exports); 1759 Mock4JS.addMockSupport(exports);
1719 })(this); 1760 })(this);
OLDNEW
« chrome/browser/resources/google_now/common_test_util.js ('K') | « chrome/chrome_tests_unit.gypi ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698