Changeset 250307 in webkit


Ignore:
Timestamp:
Sep 24, 2019 10:48:20 AM (5 years ago)
Author:
zhifei_fang@apple.com
Message:

Add tests for Ref.js.
https://bugs.webkit.org/show_bug.cgi?id=201778.

Reviewed by Jonathan Bedard.

  • resultsdbpy/resultsdbpy/view/static/library/js/Ref.js:

(applyStateDiff): null, 0, false are all valid state
(Ref.prototype.setState): We should do nothing for undefined stateDiff

  • resultsdbpy/resultsdbpy/view/static/library/js/Test.js: Added.

(AssertFailedError):
(Expect): Perform assertions during unit tests.
(Expect.prototype.isType):
(Expect.prototype.equalToValue):
(Expect.prototype.equalToHtmlWithoutRef):
(Expect.prototype.notEqualToValue):
(Expect.prototype.greaterThan):
(Expect.prototype.greaterThanOrEqualTo):
(Expect.prototype.lessThan):
(Expect.prototype.lessThanOrEqualTo):
(TestSuite): Common TestSuite class for user to extend.
(TestSuite.prototype.expect):
(TestSuite.prototype.sleep): Test will sleep for certain ms
(TestSuite.prototype.waitForSignal): Wait until we receive a certain signal with timeout
(TestSuite.prototype.waitForRefMounted): Wait until we receive ref object's onElementMount signal with timeout
(TestSuite.prototype.waitForRefUnmounted): Wait until we receive ref object's onElementUnmount signal with timeout
(TestSuite.prototype.waitForStateUpdated):Wait until we receive ref object's onStateUpdate signal with timeout
(TestSuite.prototype.async.setup): Common interface for setup a test suite
(TestSuite.prototype.async.clearUp): Common interface for clear up a test suite
(getTestFucntionNames): Collect all the test method of a test instance.
(TestResult):
(TestResult.prototype.catchException):
(async.getTestResult): Run the test and generate a TestResult object
(TestController):
(TestController.prototype.addResultHandler): Test controller will send notification of a test result to result handler
(TestController.prototype.addSetupArgs): This gives some additional args for the common setup method for each test class,
it is the best place to setup something like a root element, a fake data source, etc
(TestController.prototype.collect): This method used for collect the test classes.
(TestController.prototype.async.collectFile): It will import the file as a module dynamicly and collect all the test classes that module export
(TestController.prototype.async.runTest): It will run a test method of a test class
(TestController.prototype.async.run): It will run all test or a test class or a test method

  • resultsdbpy/resultsdbpy/view/static/library/js/components/TestComponents.js: components for test app.
  • resultsdbpy/resultsdbpy/view/static/library/js/test/RefTest.js: Ref.js test cases.
  • resultsdbpy/resultsdbpy/view/static/library/js/test/index.html: Test app entry.
Location:
trunk/Tools
Files:
5 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r250306 r250307  
     12019-09-24  Zhifei Fang  <zhifei_fang@apple.com>
     2
     3        Add tests for Ref.js.
     4        https://bugs.webkit.org/show_bug.cgi?id=201778.
     5
     6        Reviewed by Jonathan Bedard.
     7
     8        * resultsdbpy/resultsdbpy/view/static/library/js/Ref.js:
     9        (applyStateDiff): null, 0, false are all valid state
     10        (Ref.prototype.setState): We should do nothing for undefined stateDiff
     11        * resultsdbpy/resultsdbpy/view/static/library/js/Test.js: Added.
     12        (AssertFailedError):
     13        (Expect): Perform assertions during unit tests.
     14        (Expect.prototype.isType):
     15        (Expect.prototype.equalToValue):
     16        (Expect.prototype.equalToHtmlWithoutRef):
     17        (Expect.prototype.notEqualToValue):
     18        (Expect.prototype.greaterThan):
     19        (Expect.prototype.greaterThanOrEqualTo):
     20        (Expect.prototype.lessThan):
     21        (Expect.prototype.lessThanOrEqualTo):
     22        (TestSuite): Common TestSuite class for user to extend.
     23        (TestSuite.prototype.expect):
     24        (TestSuite.prototype.sleep): Test will sleep for certain ms
     25        (TestSuite.prototype.waitForSignal): Wait until we receive a certain signal with timeout
     26        (TestSuite.prototype.waitForRefMounted): Wait until we receive ref object's onElementMount signal with timeout
     27        (TestSuite.prototype.waitForRefUnmounted): Wait until we receive ref object's onElementUnmount signal with timeout
     28        (TestSuite.prototype.waitForStateUpdated):Wait until we receive ref object's onStateUpdate signal with timeout
     29        (TestSuite.prototype.async.setup): Common interface for setup a test suite
     30        (TestSuite.prototype.async.clearUp): Common interface for clear up a test suite
     31        (getTestFucntionNames): Collect all the test method of a test instance.
     32        (TestResult):
     33        (TestResult.prototype.catchException):
     34        (async.getTestResult): Run the test and generate a TestResult object
     35        (TestController):
     36        (TestController.prototype.addResultHandler): Test controller will send notification of a test result to result handler
     37        (TestController.prototype.addSetupArgs): This gives some additional args for the common setup method for each test class,
     38        it is the best place to setup something like a root element, a fake data source, etc
     39        (TestController.prototype.collect): This method used for collect the test classes.
     40        (TestController.prototype.async.collectFile): It will import the file as a module dynamicly and collect all the test classes that module export
     41        (TestController.prototype.async.runTest): It will run a test method of a test class
     42        (TestController.prototype.async.run): It will run all test or a test class or a test method
     43        * resultsdbpy/resultsdbpy/view/static/library/js/components/TestComponents.js: components for test app.
     44        * resultsdbpy/resultsdbpy/view/static/library/js/test/RefTest.js: Ref.js test cases.
     45        * resultsdbpy/resultsdbpy/view/static/library/js/test/index.html: Test app entry.
     46
    1472019-09-24  Wenson Hsieh  <wenson_hsieh@apple.com>
    248
  • trunk/Tools/resultsdbpy/resultsdbpy/view/static/library/js/Ref.js

    r248305 r250307  
    218218
    219219function applyStateDiff(state, diff) {
    220     if (!diff)
     220    if (diff === undefined)
    221221        return state;
    222222    if (!isMergeableState(diff))
     
    276276    }
    277277    setState(stateDiff) {
     278        if (stateDiff === undefined)
     279            return;
    278280        if (TRACE_STATE)
    279281            this.stateTracer.push(stateDiff);
Note: See TracChangeset for help on using the changeset viewer.