Skip to content

Commit eb6a659

Browse files
authored
Add screenrecord unittest (#426)
* Fix wrong docstring * Add screen_record unittest * Rename class names * Move test files * Fix docstring
1 parent bca75fb commit eb6a659

14 files changed

+60
-12
lines changed

appium/webdriver/extensions/screen_record.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ def start_recording_screen(self, **options):
7373
but doing so results in larger movie files.
7474
7575
Returns:
76-
bytes: Base-64 encoded content of the recorded media file or an empty string
77-
if the file has been successfully uploaded to a remote location
78-
(depends on the actual `remotePath` value).
76+
bytes: Base-64 encoded content of the recorded media
77+
if `stop_recording_screen` isn't called after previous `start_recording_screen`.
78+
Otherwise returns an empty string.
7979
"""
8080
if 'password' in options:
8181
options['pass'] = options['password']
@@ -101,7 +101,7 @@ def stop_recording_screen(self, **options):
101101
Only has an effect if `remotePath` is set.
102102
103103
Returns:
104-
bytes:Base-64 encoded content of the recorded media file or an empty string
104+
bytes: Base-64 encoded content of the recorded media file or an empty string
105105
if the file has been successfully uploaded to a remote location
106106
(depends on the actual `remotePath` value).
107107
"""

test/unit/webdriver/device/app_test.py renamed to test/unit/webdriver/app_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
)
2323

2424

25-
class TestApp(object):
25+
class TestWebDriverApp(object):
2626

2727
@httpretty.activate
2828
def test_reset(self):

test/unit/webdriver/device/context_test.py renamed to test/unit/webdriver/context_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from test.unit.helper.test_helper import android_w3c_driver, appium_command
1818

1919

20-
class TestWebDriverDeviceContext(object):
20+
class TestWebDriverContext(object):
2121

2222
@httpretty.activate
2323
def test_get_contexts(self):

test/unit/webdriver/device/activities_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
)
2222

2323

24-
class TestWebDriverDeviceActivities(object):
24+
class TestWebDriverActivities(object):
2525

2626
@httpretty.activate
2727
def test_start_activity(self):

test/unit/webdriver/device/clipboard_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
)
2525

2626

27-
class TestWebDriverDeviceClipboard(object):
27+
class TestWebDriverClipboard(object):
2828

2929
@httpretty.activate
3030
def test_set_clipboard_with_url(self):

test/unit/webdriver/device/fingerprint_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
)
2222

2323

24-
class TestWebDriverDeviceFingerprint(object):
24+
class TestWebDriverFingerprint(object):
2525

2626
@httpretty.activate
2727
def test_finger_print(self):

test/unit/webdriver/device/lock_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
)
2222

2323

24-
class TestWebDriverDeviceLock(object):
24+
class TestWebDriverLock(object):
2525

2626
@httpretty.activate
2727
def test_lock(self):

test/unit/webdriver/device/shake_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from test.unit.helper.test_helper import android_w3c_driver, appium_command
2020

2121

22-
class TestWebDriverDeviceShake(object):
22+
class TestWebDriverShake(object):
2323

2424
@httpretty.activate
2525
def test_shake(self):

test/unit/webdriver/device/execute_driver_test.py renamed to test/unit/webdriver/execute_driver_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
)
2424

2525

26-
class TestWebDriverDeviceActivities(object):
26+
class TestWebDriverExecuteDriver(object):
2727

2828
@httpretty.activate
2929
def test_batch(self):
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#
2+
# http://www.apache.org/licenses/LICENSE-2.0
3+
#
4+
# Unless required by applicable law or agreed to in writing, software
5+
# distributed under the License is distributed on an "AS IS" BASIS,
6+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7+
# See the License for the specific language governing permissions and
8+
# limitations under the License.
9+
10+
import httpretty
11+
12+
from test.unit.helper.test_helper import (
13+
android_w3c_driver,
14+
appium_command,
15+
get_httpretty_request_body
16+
)
17+
18+
19+
class TestWebDriverScreenRecord(object):
20+
21+
@httpretty.activate
22+
def test_start_recording_screen(self):
23+
driver = android_w3c_driver()
24+
httpretty.register_uri(
25+
httpretty.POST,
26+
appium_command('/session/1234567890/appium/start_recording_screen'),
27+
)
28+
assert driver.start_recording_screen(user='userA', password='12345') is None
29+
30+
d = get_httpretty_request_body(httpretty.last_request())
31+
assert d['options']['user'] == 'userA'
32+
assert d['options']['pass'] == '12345'
33+
assert 'password' not in d['options'].keys()
34+
35+
@httpretty.activate
36+
def test_stop_recording_screen(self):
37+
driver = android_w3c_driver()
38+
httpretty.register_uri(
39+
httpretty.POST,
40+
appium_command('/session/1234567890/appium/stop_recording_screen'),
41+
body='{"value": "b64_video_data"}'
42+
)
43+
assert driver.stop_recording_screen(user='userA', password='12345') == 'b64_video_data'
44+
45+
d = get_httpretty_request_body(httpretty.last_request())
46+
assert d['options']['user'] == 'userA'
47+
assert d['options']['pass'] == '12345'
48+
assert 'password' not in d['options'].keys()

0 commit comments

Comments
 (0)