def test_Connect2wifiap(self): print("Test to connect to Wifi AP") #================================ # get params from unittest.ini #================================ self.ap_name = u.getparas('wifi', 'ap_name') self.ap_password = u.getparas('wifi', 'ap_password') self.timeout = int(u.getparas('wifi', 'timeout')) #================================ # Open the Settings app self.d.server.adb.cmd( "shell am start -a android.intent.action.MAIN -n com.android.settings/.wifi.WifiSettings" ).communicate() sleep(2) self.d.wait.update() self.d(text=self.ap_name).click() forget = self.d(text="Forget").exists if forget: self.d(text="Forget").click() self.d.wait.update() self.d(text=self.ap_name).click() self.d(resourceId='com.android.settings:id/password').set_text( self.ap_password) self.d(text=u'Connect').click() assert self.d(text=u'Connected').wait.exists(timeout=self.timeout)
def test_TakePicture(self): print("Test to Camera take picture") # default value #================================= expect_filename = "expect.jpg" current_filename = "current.jpg" sleep_time = 5 threshold = 0.02 #================================ # get params from unittest.ini #================================ expect_filename = u.getparas('takepicture', 'expect_filename') current_filename = u.getparas('takepicture', 'current_filename') threshold = float(u.getparas('takepicture', 'threshold')) sleep_time = float(u.getparas('takepicture', 'sleep')) #================================ if os.path.exists(current_filename): os.remove(current_filename) expect_image_path = os.path.abspath(expect_filename) current_image_path = os.path.abspath(current_filename) beforeC = self.d.server.adb.cmd( "shell ls /sdcard/DCIM/Camera").communicate() self.d(description='Shutter').wait.exists(timeout=5000) #================================ # Take picture action #================================ self.d(resourceId="com.android.camera2:id/shutter_button").click.wait( timeout=2000) sleep(sleep_time) afterC = self.d.server.adb.cmd( "shell ls /sdcard/DCIM/Camera").communicate() if afterC == beforeC: print("take picture fail") assert False return # AfterC = ('IMG_20150513_150900.jpg\r\n', '') , it's a example # print(afterC) # Convert tuple to string filename = ''.join(afterC) filename = filename.split('\r\n')[0] # adb pull picture and rename to $current_filename self.d.server.adb.cmd("pull /sdcard/DCIM/Camera/" + filename + " ./" + current_filename).communicate() #================================ # compare two images #================================ assert os.path.exists( expect_image_path ), 'the local expected image %s not found!' % expect_image_path ret, minVal = isMatch(expect_image_path, current_image_path, threshold) if ret: print('Picture Match! , threshold = ' + str(threshold)) + ' ,minVal = ' + str(minVal) assert True else: print("Unmatch") assert False, 'Picture UnMatch! , threshold = ' + str( threshold) + ' ,minVal = ' + str(minVal)
def setup_class(self): """This method is run once for each class before any tests are run""" self.DUT_serial_no = "70400121" self.bluetooth_mac = "12:34:56:78:9A:BC" self.DUT_serial_no = u.getparas('common','DUT_serial_no') self.bluetooth_mac= u.getparas('bluetooth','bluetooth_mac') self.d = Device(self.DUT_serial_no)
def setup_class(self): """This method is run once for each class before any tests are run""" #criterion self.sound_min=60.0 self.sound_max=73.0 self.light_min=15.0 self.light_max=20.0 self.g_xmin=-0.40 self.g_xmax=-0.20 self.g_ymin=-2.50 self.g_ymax=-1.90 self.DUT_serial_no = "70400121" #================================ # get params from unittest.ini #================================ self.DUT_serial_no = u.getparas('common','DUT_serial_no') self.g_xmin = float(u.getparas('gsensor','spec_xmin')) self.g_xmax = float(u.getparas('gsensor','spec_xmax')) self.g_ymin = float(u.getparas('gsensor','spec_ymin')) self.g_ymax = float(u.getparas('gsensor','spec_ymax')) self.sound_min = float(u.getparas('sound','spec_min')) self.sound_max = float(u.getparas('sound','spec_max')) self.light_min = float(u.getparas('light','spec_min')) self.light_max = float(u.getparas('light','spec_max')) #================================ self.d = Device(self.DUT_serial_no) #Install Meter toolbox apk ret = self.d.server.adb.cmd("install -r ./Meter\ Toolbox_1.1.2_14.apk").communicate() if not ret: print("Failure to install Meter Toolbox apk") else: print("install Meter toolbox apk sucessfuly") self.d.press.home()
def setup_class(self): """This method is run once for each class before any tests are run""" self.DUT_serial_no = "70400121" self.wifi_mac = "12:34:56:78:9A:BC" self.DUT_serial_no = u.getparas('common', 'DUT_serial_no') self.wifi_mac = u.getparas('wifi', 'wifi_mac') self.d = Device(self.DUT_serial_no) u.setup(self.d) self.ap_name = 'dlink-549' self.ap_password = '******' self.d.press.home()
def setup_class(self): """This method is run once for each class before any tests are run""" self.DUT_serial_no = "70400121" self.wifi_mac = "12:34:56:78:9A:BC" self.DUT_serial_no = u.getparas('common','DUT_serial_no') self.wifi_mac= u.getparas('wifi','wifi_mac') self.d = Device(self.DUT_serial_no) u.setup(self.d) self.ap_name='dlink-549' self.ap_password='******' self.d.press.home()
def test_TakePicture(self): print("Test to Camera take picture") # default value #================================= expect_filename = "expect.jpg" current_filename = "current.jpg" sleep_time = 5 threshold = 0.02 #================================ # get params from unittest.ini #================================ expect_filename = u.getparas('takepicture','expect_filename') current_filename = u.getparas('takepicture','current_filename') threshold = float(u.getparas('takepicture','threshold')) sleep_time = float(u.getparas('takepicture','sleep')) #================================ if os.path.exists(current_filename): os.remove(current_filename) expect_image_path = os.path.abspath(expect_filename) current_image_path = os.path.abspath(current_filename) beforeC = self.d.server.adb.cmd("shell ls /sdcard/DCIM/Camera").communicate() self.d(description='Shutter').wait.exists(timeout=5000) #================================ # Take picture action #================================ self.d(resourceId="com.android.camera2:id/shutter_button").click.wait(timeout=2000) sleep(sleep_time) afterC = self.d.server.adb.cmd("shell ls /sdcard/DCIM/Camera").communicate() if afterC == beforeC: print("take picture fail") assert False return # AfterC = ('IMG_20150513_150900.jpg\r\n', '') , it's a example # print(afterC) # Convert tuple to string filename=''.join(afterC) filename=filename.split('\r\n')[0] # adb pull picture and rename to $current_filename self.d.server.adb.cmd("pull /sdcard/DCIM/Camera/" + filename +" ./"+ current_filename ).communicate() #================================ # compare two images #================================ assert os.path.exists(expect_image_path), 'the local expected image %s not found!' % expect_image_path ret, minVal = isMatch(expect_image_path , current_image_path, threshold) if ret: print('Picture Match! , threshold = ' + str(threshold)) + ' ,minVal = ' + str(minVal) assert True else: print("Unmatch") assert False, 'Picture UnMatch! , threshold = ' + str(threshold) + ' ,minVal = ' + str(minVal)
def setup_class(self): """This method is run once for each class before any tests are run""" self.DUT_serial_no = "70400121" self.storage_int_min = 11.00 self.storage_int_max = 12.00 self.storage_ext_min = 30.00 self.storage_ext_max = 32.00 self.storage_int_min = float(u.getparas('storage', 'storage_int_min')) self.storage_int_max = float(u.getparas('storage', 'storage_int_max')) self.storage_ext_min = float(u.getparas('storage', 'storage_ext_min')) self.storage_ext_max = float(u.getparas('storage', 'storage_ext_max')) self.DUT_serial_no = u.getparas('common', 'DUT_serial_no') self.d = Device(self.DUT_serial_no) u.setup(self.d)
def test_Search_Bluetooth_Devices(self): print("Test to search BT Devices") #================================ # get params from unittest.ini #================================ self.timeout = int(u.getparas('bluetooth','timeout')) #================================ # Open the Settings app self.d.server.adb.cmd("shell am start -a android.intent.action.MAIN -n com.android.settings/.bluetooth.BluetoothSettings"). \ communicate() if self.d(text="OFF").exists: self.d(text="OFF").click() sleep(3) else: self.d(text="ON").click() sleep(3) self.d(text="OFF").click() sleep(3) self.d.wait.update() ret = self.d(text="Search for devices").wait.exists(timeout=self.timeout) print("The string of search for devices is found ? = " + str(ret)) avl = self.d(className="android.widget.ListView").child_by_text("Available devices").childCount # child 1 FARTMB611Y # child 2 Available devices # after child 3 searched devices. "No nearby Bluetooth devices were found." found=self.d(text="No nearby Bluetooth devices were found.").exists print("The string of No nearby Bluetooth devices were found." "? = " + str(found)) if found: avl = avl -1 print("Number of devices has been found = " + str(avl-2)) assert avl > 2 and found == False
def setup_class(self): """This method is run once for each class before any tests are run""" #criterion , TODO: need to redefine them. self.DUT_serial_no = "70400121" self.DUT_serial_no = u.getparas('common','DUT_serial_no') self.d = Device(self.DUT_serial_no) self.d.server.adb.cmd("shell rm /sdcard/DCIM/Camera/*").communicate() self.d.server.adb.cmd("shell refresh /sdcard/DCIM/Camera").communicate()
def setup_class(self): """This method is run once for each class before any tests are run""" #criterion , TODO: need to redefine them. self.DUT_serial_no = "70400121" self.DUT_serial_no = u.getparas('common', 'DUT_serial_no') self.d = Device(self.DUT_serial_no) self.d.server.adb.cmd("shell rm /sdcard/DCIM/Camera/*").communicate() self.d.server.adb.cmd( "shell refresh /sdcard/DCIM/Camera").communicate()
def setup_class(self): """This method is run once for each class before any tests are run""" #Initial value (criterion ) self.fixture_serial_no = "f0e673e1" self.DUT_serial_no = "70400121" self.dbm_max_audio = 6000 self.dbm_min_audio = 4800 record_filename = 'record' # record.wav , record.png self.wav_filename = record_filename + '.wav' self.png_filename = record_filename + '.png' #================================ # get params from unittest.ini #================================ self.fixture_serial_no = u.getparas('audio','fixture_serial_no') self.DUT_serial_no = u.getparas('audio','DUT_serial_no') self.dbm_max_audio = float(u.getparas('audio','dbm_max_audio')) self.dbm_min_audio = float(u.getparas('audio','dbm_min_audio')) self.wav_filename = u.getparas('audio','wavfile') self.png_filename = u.getparas('audio','pngfile') #================================ # Initial Fixture as self.f self.f = Device(self.fixture_serial_no) self.f.wav_filename = self.wav_filename # Initial DUT as self.d self.d = Device(self.DUT_serial_no) # Install Signal Generator apk ret = self.d.server.adb.cmd("install -r ./Signal\ Generator_1.21_6.apk").communicate() if not ret: print("Failure to install Signal Generator apk") else: print("Sucessful to install Signal Generator apk") record_init(self.f)
def setup_class(self): """This method is run once for each class before any tests are run""" #Initial value (criterion ) self.fixture_serial_no = "f0e673e1" self.DUT_serial_no = "70400121" self.dbm_max_audio = 6000 self.dbm_min_audio = 4800 record_filename = 'record' # record.wav , record.png self.wav_filename = record_filename + '.wav' self.png_filename = record_filename + '.png' #================================ # get params from unittest.ini #================================ self.fixture_serial_no = u.getparas('audio', 'fixture_serial_no') self.DUT_serial_no = u.getparas('audio', 'DUT_serial_no') self.dbm_max_audio = float(u.getparas('audio', 'dbm_max_audio')) self.dbm_min_audio = float(u.getparas('audio', 'dbm_min_audio')) self.wav_filename = u.getparas('audio', 'wavfile') self.png_filename = u.getparas('audio', 'pngfile') #================================ # Initial Fixture as self.f self.f = Device(self.fixture_serial_no) self.f.wav_filename = self.wav_filename # Initial DUT as self.d self.d = Device(self.DUT_serial_no) # Install Signal Generator apk ret = self.d.server.adb.cmd( "install -r ./Signal\ Generator_1.21_6.apk").communicate() if not ret: print("Failure to install Signal Generator apk") else: print("Sucessful to install Signal Generator apk") record_init(self.f)
def test_Connect2wifiap(self): print("Test to connect to Wifi AP") #================================ # get params from unittest.ini #================================ self.ap_name = u.getparas('wifi','ap_name') self.ap_password = u.getparas('wifi','ap_password') self.timeout = int(u.getparas('wifi','timeout')) #================================ # Open the Settings app self.d.server.adb.cmd("shell am start -a android.intent.action.MAIN -n com.android.settings/.wifi.WifiSettings").communicate() sleep(2) self.d.wait.update() self.d(text=self.ap_name).click() forget=self.d(text="Forget").exists if forget: self.d(text="Forget").click() self.d.wait.update() self.d(text=self.ap_name).click() self.d(resourceId='com.android.settings:id/password').set_text(self.ap_password) self.d(text=u'Connect').click() assert self.d(text=u'Connected').wait.exists(timeout=self.timeout)
def setup_class(self): """This method is run once for each class before any tests are run""" #Initial value (criterion ) self.fixture_serial_no = "f0e673e1" self.DUT_serial_no = "70400121" self.lux_max_lcd_on = 50 self.lux_min_lcd_on = 40 self.lux_max_lcd_off = 10 self.lux_min_lcd_off = 20 #================================ # get params from unittest.ini #================================ self.fixture_serial_no = u.getparas('lcd', 'fixture_serial_no') self.DUT_serial_no = u.getparas('lcd', 'DUT_serial_no') self.lux_max_lcd_on = float(u.getparas('lcd', 'lux_max_lcd_on')) self.lux_min_lcd_on = float(u.getparas('lcd', 'lux_min_lcd_on')) self.lux_max_lcd_off = float(u.getparas('lcd', 'lux_max_lcd_off')) self.lux_min_lcd_off = float(u.getparas('lcd', 'lux_min_lcd_off')) #================================ # Initial Fixture as self.f self.f = Device(self.fixture_serial_no) # Initial DUT as self.d self.d = Device(self.DUT_serial_no) #Install Meter toolbox apk ret = self.f.server.adb.cmd( "install -r ./Meter\ Toolbox_1.1.2_14.apk").communicate() if not ret: print("Failure to install Meter Toolbox apk") else: print("install Meter toolbox apk sucessfuly") # Install Display Tester apk ret = self.d.server.adb.cmd( "install -r ./Display\ Tester_1.2_4.apk").communicate() if not ret: print("Failure to install Display Tester apk") else: print("Sucessful to install Display Tester apk")
def setup_class(self): """This method is run once for each class before any tests are run""" #criterion , TODO: need to redefine them. self.g_xmin=-0.0800 self.g_xmax=-0.0300 self.g_ymin=-0.500 self.g_ymax=-0.300 self.g_zmin=10.250 self.g_zmax=10.400 self.gyro_xmin=-1 self.gyro_xmax=1 self.gyro_ymin=-1 self.gyro_ymax=1 self.gyro_zmin=-1 self.gyro_zmax=1 self.mag_xmin=10 self.mag_xmax=50 self.mag_ymin=-100 self.mag_ymax=50 self.mag_zmin=-50 self.mag_zmax=50 self.light_min = 0 self.light_max = 100 self.DUT_serial_no = "70400121" #================================ # get params from unittest.ini #================================ self.DUT_serial_no = u.getparas('common','DUT_serial_no') self.g_xmin = float(u.getparas('gsensor','spec_xmin')) self.g_xmax = float(u.getparas('gsensor','spec_xmax')) self.g_ymin = float(u.getparas('gsensor','spec_ymin')) self.g_ymax = float(u.getparas('gsensor','spec_ymax')) self.g_zmin = float(u.getparas('gsensor','spec_zmin')) self.g_zmax = float(u.getparas('gsensor','spec_zmax')) self.gyro_xmin = float(u.getparas('gyro','spec_xmin')) self.gyro_xmax = float(u.getparas('gyro','spec_xmax')) self.gyro_ymin = float(u.getparas('gyro','spec_ymin')) self.gyro_ymax = float(u.getparas('gyro','spec_ymax')) self.gyro_zmin = float(u.getparas('gyro','spec_zmin')) self.gyro_zmax = float(u.getparas('gyro','spec_zmax')) self.mag_xmin = float(u.getparas('mag','spec_xmin')) self.mag_xmax = float(u.getparas('mag','spec_xmax')) self.mag_ymin = float(u.getparas('mag','spec_ymin')) self.mag_ymax = float(u.getparas('mag','spec_ymax')) self.mag_zmin = float(u.getparas('mag','spec_zmin')) self.mag_zmax = float(u.getparas('mag','spec_zmax')) self.light_min = float(u.getparas('light','spec_min')) self.light_max = float(u.getparas('light','spec_max')) #================================ self.d = Device(self.DUT_serial_no) ret = self.d.server.adb.cmd("install -r ./Z-DeviceTest_1.7_47.apk").communicate() if not ret: print("Failure to install Z-DeviceTest") else: print("Sucessful to install Z-DeviceTest")