Skip to content

Commit 07a5894

Browse files
ki4070mamanoj9788
authored andcommitted
Add IME unittest (appium#475)
1 parent 8779c3d commit 07a5894

2 files changed

Lines changed: 98 additions & 0 deletions

File tree

test/unit/webdriver/ime_test.py

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
#!/usr/bin/env python
2+
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
16+
import json
17+
18+
import httpretty
19+
20+
from appium.webdriver.webdriver import WebDriver
21+
from test.unit.helper.test_helper import (
22+
android_w3c_driver,
23+
appium_command,
24+
get_httpretty_request_body
25+
)
26+
27+
28+
class TestWebDriverIme(object):
29+
30+
@httpretty.activate
31+
def test_available_ime_engines(self):
32+
ANDROID_LATIN = 'com.android.inputmethod.latin/.LatinIME'
33+
GOOGLE_LATIN = 'com.google.android.inputmethod.latin/com.android.inputmethod.latin.LatinIME'
34+
35+
driver = android_w3c_driver()
36+
httpretty.register_uri(
37+
httpretty.GET,
38+
appium_command('/session/1234567890/ime/available_engines'),
39+
body=json.dumps({'value': [ANDROID_LATIN, GOOGLE_LATIN]})
40+
)
41+
assert driver.available_ime_engines == [ANDROID_LATIN, GOOGLE_LATIN]
42+
43+
@httpretty.activate
44+
def test_is_ime_active(self):
45+
driver = android_w3c_driver()
46+
httpretty.register_uri(
47+
httpretty.GET,
48+
appium_command('/session/1234567890/ime/activated'),
49+
body=json.dumps({'value': True})
50+
)
51+
assert driver.is_ime_active() is True
52+
53+
@httpretty.activate
54+
def test_activate_ime_engine(self):
55+
driver = android_w3c_driver()
56+
httpretty.register_uri(
57+
httpretty.POST,
58+
appium_command('/session/1234567890/ime/activate'),
59+
)
60+
engine = 'com.android.inputmethod.latin/.LatinIME'
61+
assert isinstance(driver.activate_ime_engine(engine), WebDriver)
62+
63+
d = get_httpretty_request_body(httpretty.last_request())
64+
assert d['engine'] == 'com.android.inputmethod.latin/.LatinIME'
65+
66+
@httpretty.activate
67+
def test_deactivate_ime_engine(self):
68+
driver = android_w3c_driver()
69+
httpretty.register_uri(
70+
httpretty.POST,
71+
appium_command('/session/1234567890/ime/deactivate'),
72+
)
73+
assert isinstance(driver.deactivate_ime_engine(), WebDriver)
74+
75+
@httpretty.activate
76+
def test_active_ime_engine(self):
77+
driver = android_w3c_driver()
78+
httpretty.register_uri(
79+
httpretty.GET,
80+
appium_command('/session/1234567890/ime/active_engine'),
81+
body=json.dumps({'value': 'com.android.inputmethod.latin/.LatinIME'})
82+
)
83+
assert driver.active_ime_engine == 'com.android.inputmethod.latin/.LatinIME'

test/unit/webdriver/nativekey_test.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
#!/usr/bin/env python
2+
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
116
from appium.webdriver.extensions.android.nativekey import AndroidKey
217

318

0 commit comments

Comments
 (0)