Repository: incubator-weex
Updated Branches:
  refs/heads/0.13-dev 0c50691dd -> 9cf46623b


+ [test] Add maraca test case of timer


Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/9cf46623
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/9cf46623
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/9cf46623

Branch: refs/heads/0.13-dev
Commit: 9cf46623bed016816fefb8c2d5b18e142094a23e
Parents: 0c50691
Author: YorkShen <shenyua...@gmail.com>
Authored: Fri Apr 21 16:45:17 2017 +0800
Committer: YorkShen <shenyua...@gmail.com>
Committed: Tue May 2 16:01:58 2017 +0800

----------------------------------------------------------------------
 test/pages/modules/vue_timer.vue     |  75 ++++++++++++++++++++++
 test/pages/modules/we_timer.we       |  73 ++++++++++++++++++++++
 test/scripts/components/text.test.js |   2 +-
 test/scripts/modules/timer.test.js   | 100 ++++++++++++++++++++++++++++++
 4 files changed, 249 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/9cf46623/test/pages/modules/vue_timer.vue
----------------------------------------------------------------------
diff --git a/test/pages/modules/vue_timer.vue b/test/pages/modules/vue_timer.vue
new file mode 100644
index 0000000..a4bd79e
--- /dev/null
+++ b/test/pages/modules/vue_timer.vue
@@ -0,0 +1,75 @@
+<template>
+    <div>
+        <text>setTimeout timeout=5000</text>
+        <div class="wrapper">
+            <text test-id="setTimeout" class="t" 
@click="stimeout">SetTimeOut</text>
+            <text test-id="clearTimeout" class="t" 
@click="ctimeout">ClearTimeOut</text>
+        </div>
+        <text class="content" test-id="timeout">{{timeout_content}}</text>
+
+        <text style="margin-top: 100px">setInterval interval=5000</text>
+        <div style="background-color:red" class="wrapper">
+            <text test-id="setInterval" class="t" 
@click="sinterval">SetInterval</text>
+            <text test-id="clearInterval" class="t" 
@click="cinterval">ClearInterval</text>
+        </div>
+        <text test-id="interval" class="content">{{interval_content}}</text>
+    </div>
+</template>
+
+<style>
+    .wrapper {
+        height: 100px;
+        width: 750px;
+        background-color: yellow;
+        align-items: center;
+        flex-direction: row
+    }
+
+    .t {
+        font-size: 36px;
+        color: #ffffff;
+        align-items: center;
+        flex: 1;
+        text-align: center;
+    }
+
+    .content {
+        font-size: 32px;
+        background-color: blue;
+        color: black;
+        text-align: center;
+    }
+</style>
+
+<script>
+    var tfnId;
+    var ifnId;
+    module.exports = {
+        data: function () {
+            return {
+                timeout_content: 0,
+                interval_content: 0
+            }
+        },
+        methods: {
+            stimeout: function () {
+                var self = this;
+                tfnId = setTimeout(function () {
+                    self.timeout_content += 1
+                }, 5000);
+            },
+            ctimeout: function () {
+                clearTimeout(tfnId)
+            },
+            sinterval: function () {
+                var self = this;
+                ifnId = setInterval(function () {
+                    self.interval_content += 1
+                }, 5000);
+            },
+            cinterval: function () {
+                clearInterval(ifnId)
+            }
+        }
+    }
+</script>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/9cf46623/test/pages/modules/we_timer.we
----------------------------------------------------------------------
diff --git a/test/pages/modules/we_timer.we b/test/pages/modules/we_timer.we
new file mode 100644
index 0000000..ce683c5
--- /dev/null
+++ b/test/pages/modules/we_timer.we
@@ -0,0 +1,73 @@
+<template>
+    <div>
+        <text>setTimeout timeout=5000</text>
+        <div class="wrapper">
+            <text test-id="setTimeout" class="t" 
onclick="stimeout">SetTimeOut</text>
+            <text test-id="clearTimeout" class="t" 
onclick="ctimeout">ClearTimeOut</text>
+        </div>
+        <text class="content" test-id="timeout">{{timeout_content}}</text>
+
+        <text style="margin-top: 100px">setInterval interval=5000</text>
+        <div style="background-color:red" class="wrapper">
+            <text test-id="setInterval" class="t" 
onclick="sinterval">SetInterval</text>
+            <text test-id="clearInterval" class="t" 
onclick="cinterval">ClearInterval</text>
+        </div>
+        <text test-id="interval" class="content">{{interval_content}}</text>
+    </div>
+</template>
+
+<style>
+    .wrapper {
+        height: 100px;
+        width: 750px;
+        background-color: yellow;
+        align-items: center;
+        flex-direction: row
+    }
+
+    .t {
+        font-size: 36px;
+        color: #ffffff;
+        align-items: center;
+        flex: 1;
+        text-align: center;
+    }
+
+    .content {
+        font-size: 32px;
+        background-color: blue;
+        color: black;
+        text-align: center;
+    }
+</style>
+
+<script>
+    var tfnId;
+    var ifnId;
+    module.exports = {
+        data: {
+            timeout_content: 0,
+            interval_content: 0
+        },
+        methods: {
+            stimeout: function () {
+                var self = this;
+                tfnId = setTimeout(function () {
+                    self.timeout_content += 1
+                }, 5000);
+            },
+            ctimeout: function () {
+                clearTimeout(tfnId)
+            },
+            sinterval: function () {
+                var self = this;
+                ifnId = setInterval(function () {
+                    self.interval_content += 1
+                }, 5000);
+            },
+            cinterval: function () {
+                clearInterval(ifnId)
+            }
+        }
+    }
+</script>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/9cf46623/test/scripts/components/text.test.js
----------------------------------------------------------------------
diff --git a/test/scripts/components/text.test.js 
b/test/scripts/components/text.test.js
index 0c867cf..4d45472 100644
--- a/test/scripts/components/text.test.js
+++ b/test/scripts/components/text.test.js
@@ -18,7 +18,7 @@ describe('weex text @ignore-ios', function () {
   });
 
   after(function () {
-    // return util.quit(driver);
+    return util.quit(driver);
   })
 
 

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/9cf46623/test/scripts/modules/timer.test.js
----------------------------------------------------------------------
diff --git a/test/scripts/modules/timer.test.js 
b/test/scripts/modules/timer.test.js
new file mode 100644
index 0000000..5b26667
--- /dev/null
+++ b/test/scripts/modules/timer.test.js
@@ -0,0 +1,100 @@
+'use strict';
+
+var _ = require('macaca-utils');
+var assert = require('chai').assert
+var wd = require('weex-wd')
+var path = require('path');
+var os = require('os');
+var util = require("../util.js");
+
+do_test('Time Module in .we', '/modules/we_timer.js');
+
+do_test('Time Module in .vue', '/modules/vue_timer.js');
+
+function do_test(test_title, url) {
+  describe(test_title, function () {
+    this.timeout(util.getTimeoutMills());
+    var driver = util.createDriver(wd);
+
+    before(function () {
+      return util.init(driver)
+        .get(util.getPage(url))
+        .waitForElementById("interval", util.getGETActionWaitTimeMills(), 1000)
+    });
+
+    after(function () {
+      return util.quit(driver);
+    })
+
+    it('#1 SetTimeOut', () => {
+      return driver
+        .elementById('setTimeout')
+        .click()
+        .sleep(6000)
+        .click()
+        .sleep(6000)
+        .elementById('timeout')
+        .text()
+        .then(text => {
+          assert.equal(text, 2)
+        })
+    })
+
+    it('#2 SetTimeOut Double click', () => {
+      return driver
+        .elementById('setTimeout')
+        .click()
+        .click()
+        .sleep(6000)
+        .elementById('timeout')
+        .text()
+        .then(text => {
+          assert.equal(text, 4)
+        })
+    })
+
+    it('#3 ClearTimeOut', () => {
+      return driver
+        .elementById('setTimeout')
+        .click()
+        .elementById('clearTimeout')
+        .click()
+        .sleep(6000)
+        .elementById('timeout')
+        .text()
+        .then(text => {
+          assert.equal(text, 4)
+        })
+    })
+
+    it('#4 SetInterval', () => {
+      return driver
+        .elementById('setInterval')
+        .click()
+        .sleep(11000)
+        .elementById('interval')
+        .text()
+        .then(text => {
+          assert.equal(text, 2)
+        })
+    })
+
+    let previous = 0
+    it('#5 ClearInterval', () => {
+      return driver
+        .elementById('clearInterval')
+        .click()
+        .elementById('interval')
+        .text()
+        .then(text => {
+          previous = text
+        })
+        .sleep(7000)
+        .elementById('interval')
+        .text()
+        .then(text => {
+          assert.equal(previous, text)
+        })
+    })
+  })
+}
\ No newline at end of file

Reply via email to