first attempt

Former-commit-id: dc2839e086
This commit is contained in:
Roman Volosovskyi 2016-05-26 15:31:11 +03:00
parent 9888eaab18
commit c10abb17bb
5 changed files with 106 additions and 11 deletions

4
.gitignore vendored
View File

@ -50,3 +50,7 @@ target/
#
figwheel_server.log
.nrepl-port
# Lein
#
.lein-failures

View File

@ -8,7 +8,7 @@
[reagent "0.5.1" :exclusions [cljsjs/react]]
[re-frame "0.6.0"]
[prismatic/schema "1.0.4"]
^{:voom {:repo "https://github.com/status-im/status-lib.git"
^{:voom {:repo "git@github.com:status-im/status-lib.git"
:branch "master"}}
[status-im/protocol "0.1.1-20160525_083359-g53ab2c2"]
[natal-shell "0.1.6"]
@ -22,7 +22,9 @@
["with-profile" "prod" "cljsbuild" "once" "android"]]}
:figwheel {:nrepl-port 7888}
:profiles {:dev {:dependencies [[figwheel-sidecar "0.5.0-2"]
[com.cemerick/piggieback "0.2.1"]]
[com.cemerick/piggieback "0.2.1"]
[io.appium/java-client "3.4.1"]
]
:source-paths ["src" "env/dev"]
:cljsbuild {:builds {:ios {:source-paths ["src" "env/dev"]
:figwheel true
@ -46,5 +48,4 @@
:compiler {:output-to "index.android.js"
:main "env.android.main"
:output-dir "target/android"
:optimizations :simple}}}}
}})
:optimizations :simple}}}}}})

53
test/status_im/appium.clj Normal file
View File

@ -0,0 +1,53 @@
(ns status-im.appium
(:require [clojure.java.io :as io]
[clojure.test :refer :all])
(:import (org.openqa.selenium.remote DesiredCapabilities)
(org.openqa.selenium By)
(io.appium.java_client.android AndroidDriver)
(java.net URL)
(java.util.concurrent TimeUnit)))
(defn init []
(let [dir (io/file (str (System/getProperty "user.dir")
"/android/app/build/outputs/apk"))
app (io/file dir "app-debug.apk")
capabilities (doto (DesiredCapabilities.)
(.setCapability "deviceName" "device")
(.setCapability "platformVersion" "6.0.0")
(.setCapability "app" (.getAbsolutePath app))
(.setCapability "appPackage" "com.statusim")
(.setCapability "appActivity" ".MainActivity"))
driver (AndroidDriver. (URL. "http://127.0.0.1:4723/wd/hub") capabilities)]
(-> driver
.manage
.timeouts
(.implicitlyWait 100 TimeUnit/MILLISECONDS))
(Thread/sleep 9000)
driver))
(defn by-xpath [driver xpath]
(.findElement driver (By/xpath xpath)))
(defn elements-by-xpath [driver xpath]
(.findElements driver (By/xpath xpath)))
(defn click [driver xpath]
(.click (by-xpath driver xpath)))
(defn write [driver input-xpath text]
(.sendKeys (by-xpath driver input-xpath) (into-array [text])))
(defn get-text [driver xpath]
(.getText (by-xpath driver xpath)))
(defn xpath-by-text [text]
(str ".//*[@text='" text "']" ))
(defn contains-text [driver text]
(is (= 1 (->> (xpath-by-text text)
(elements-by-xpath driver)
(.size)))))
(defn quit [driver]
(.quit driver))

View File

@ -0,0 +1,44 @@
(ns status-im.console
(:require [clojure.test :refer :all]
[status-im.appium :refer :all]))
(def command-request-icon
(str
"//android.widget.LinearLayout[1]/android.widget.FrameLayout[1]"
"/android.widget.FrameLayout[1]/android.view.ViewGroup[1]"
"/android.widget.ScrollView[1]/android.view.ViewGroup[1]"
"/android.view.ViewGroup[1]/android.view.ViewGroup[1]"
"/android.view.ViewGroup[2]/android.widget.ImageView[1]"))
(def input
(str
"//android.widget.LinearLayout[1]/android.widget.FrameLayout[1]"
"/android.widget.FrameLayout[1]/android.view.ViewGroup[1]"
"/android.view.ViewGroup[2]/android.view.ViewGroup[1]"
"/android.widget.EditText[1]"))
(def send-button1
(str "//android.widget.LinearLayout[1]/android.widget.FrameLayout[1]"
"/android.widget.FrameLayout[1]/android.view.ViewGroup[1]"
"/android.view.ViewGroup[2]/android.view.ViewGroup[1]"
"/android.view.ViewGroup[2]/android.view.ViewGroup[1]"))
(def send-button2
(str "//android.widget.LinearLayout[1]/android.widget.FrameLayout[1]"
"/android.widget.FrameLayout[1]/android.view.ViewGroup[1]"
"/android.view.ViewGroup[2]/android.view.ViewGroup[2]"
"/android.view.ViewGroup[2]/android.view.ViewGroup[1]"))
(def message-text
(str "Your phone number is also required to use the app. Type"
" the exclamation mark or hit the icon to open the command "
"list and choose the !phone command"))
(deftest console-test
(let [driver (init)]
(click driver command-request-icon)
(write driver input "123")
(click driver send-button1)
(click driver send-button2)
(contains-text driver message-text)
(quit driver)))

View File

@ -1,7 +0,0 @@
(ns status-im.core-test
(:require [clojure.test :refer :all]
[status-im.core :refer :all]))
(deftest a-test
(testing "FIXME, I fail."
(is (= 0 1))))