From 63dd0d4a4a63c1d71bcafe6b7e56ecc00fd3c9aa Mon Sep 17 00:00:00 2001 From: Roman Volosovskyi Date: Thu, 26 May 2016 16:46:14 +0300 Subject: [PATCH] :accessibility-label --- src/status_im/chat/views/command.cljs | 6 ++-- src/status_im/chat/views/message.cljs | 7 ++++- src/status_im/chat/views/plain_input.cljs | 19 ++++++------ test/status_im/appium.clj | 14 +++++++-- test/status_im/console.clj | 35 +++-------------------- 5 files changed, 35 insertions(+), 46 deletions(-) diff --git a/src/status_im/chat/views/command.cljs b/src/status_im/chat/views/command.cljs index ab90de0426..2b550dc7bf 100644 --- a/src/status_im/chat/views/command.cljs +++ b/src/status_im/chat/views/command.cljs @@ -38,11 +38,13 @@ :onChangeText set-input-message :onSubmitEditing (fn [] (when (valid? message validator) - (send-command)))} + (send-command))) + :accessibility-label :command-input} input-options) message] (if (valid? message validator) - [touchable-highlight {:on-press send-command} + [touchable-highlight {:on-press send-command + :accessibility-label :stage-command} [view st/send-container [icon :send st/send-icon]]] [touchable-highlight {:on-press cancel-command-input} [view st/cancel-container diff --git a/src/status_im/chat/views/message.cljs b/src/status_im/chat/views/message.cljs index d1b9750f5f..ceb430fc76 100644 --- a/src/status_im/chat/views/message.cljs +++ b/src/status_im/chat/views/message.cljs @@ -72,13 +72,18 @@ (defn set-chat-command [msg-id command] (dispatch [:set-response-chat-command msg-id (:command command)])) +(defn label [{:keys [command]}] + (->> (name command) + (str "request-"))) + (defn message-content-command-request [{:keys [msg-id content from incoming-group]}] (let [commands-atom (subscribe [:get-commands])] (fn [{:keys [msg-id content from incoming-group]}] (let [commands @commands-atom {:keys [command content]} (parse-command-request commands content)] - [touchable-highlight {:onPress #(set-chat-command msg-id command)} + [touchable-highlight {:onPress #(set-chat-command msg-id command) + :accessibility-label (label command)} [view st/comand-request-view [view st/command-request-message-view (when incoming-group diff --git a/src/status_im/chat/views/plain_input.cljs b/src/status_im/chat/views/plain_input.cljs index eaece17dfb..dcbc75780a 100644 --- a/src/status_im/chat/views/plain_input.cljs +++ b/src/status_im/chat/views/plain_input.cljs @@ -1,9 +1,9 @@ (ns status-im.chat.views.plain-input (:require [re-frame.core :refer [subscribe dispatch]] [status-im.components.react :refer [view - icon - touchable-highlight - text-input]] + icon + touchable-highlight + text-input]] [status-im.chat.views.suggestions :refer [suggestions-view]] [status-im.chat.styles.plain-input :as st])) @@ -39,15 +39,16 @@ (if @typing-command? [icon :close-gray st/close-icon] [icon :list st/list-icon])]] - [text-input {:style st/message-input - :autoFocus (pos? (count @staged-commands-atom)) - :onChangeText set-input-message - :onSubmitEditing #(try-send @chat @staged-commands-atom - input-message)} + [text-input {:style st/message-input + :autoFocus (pos? (count @staged-commands-atom)) + :onChangeText set-input-message + :onSubmitEditing #(try-send @chat @staged-commands-atom + input-message)} input-message] ;; TODO emoticons: not implemented [icon :smile st/smile-icon] (when (message-valid? @staged-commands-atom input-message) - [touchable-highlight {:on-press #(send @chat input-message)} + [touchable-highlight {:on-press #(send @chat input-message) + :accessibility-label :send-message} [view st/send-container [icon :send st/send-icon]]])]])))) diff --git a/test/status_im/appium.clj b/test/status_im/appium.clj index a879a68ba2..7a857711de 100644 --- a/test/status_im/appium.clj +++ b/test/status_im/appium.clj @@ -32,11 +32,19 @@ (defn elements-by-xpath [driver xpath] (.findElements driver (By/xpath xpath))) -(defn click [driver xpath] - (.click (by-xpath driver xpath))) +(defn by-id [driver id] + (.findElementByAccessibilityId driver (name id))) + +(defn get-element [driver id] + (if (keyword? id) + (by-id driver id) + (by-xpath driver id))) + +(defn click [driver id] + (.click (get-element driver id))) (defn write [driver input-xpath text] - (.sendKeys (by-xpath driver input-xpath) (into-array [text]))) + (.sendKeys (get-element driver input-xpath) (into-array [text]))) (defn get-text [driver xpath] (.getText (by-xpath driver xpath))) diff --git a/test/status_im/console.clj b/test/status_im/console.clj index a99251393d..4d748af7c2 100644 --- a/test/status_im/console.clj +++ b/test/status_im/console.clj @@ -2,33 +2,6 @@ (: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 " @@ -36,9 +9,9 @@ (deftest console-test (let [driver (init)] - (click driver command-request-icon) - (write driver input "123") - (click driver send-button1) - (click driver send-button2) + (click driver :request-keypair-password) + (write driver :command-input "123") + (click driver :stage-command) + (click driver :send-message) (contains-text driver message-text) (quit driver)))