class SleepTimeInLockScreen(UIATestBase): def setUp(self): self._test_name = __name__ print print "[Setup]: %s" % self._test_name self.energy = Energy() self.logcat = Logcat(filter_tag="PowerManagerService", grep_opt="grep -c 'Going to sleep'") def tearDown(self): print "[Teardown]: %s" % self._test_name time.sleep(2) super(SleepTimeInLockScreen, self).tearDown() def test_sleep_time_in_lock_screen(self): """ Test_Check_the_sleep_time_in_lock_screen_after_USB_unplugged """ print "[RunTest]: %s" % self.__str__() self.energy.set_screen_status("off") time.sleep(2) self.energy.set_screen_status("on") time.sleep(1) self.logcat.set_start_time() log = self.logcat.get_log() assert int(log) == 0 USBCut().cut(15) log = self.logcat.get_log() assert int(log) == 1
class root_system_permission_sysfs(UIATestBase): def setUp(self): self._test_name = __name__ print "[Setup]: %s" % self._test_name self.energy = Energy() self.energy.adb_root() def tearDown(self): print "[Teardown]: %s" % self._test_name def test_root_system_permission_sysfs(self): print "[RunTest]: %s" % self.__str__() cmd1 = "cat /sys/class/power_supply/dollar_cove_battery/uevent" cmd2 = "cat /sys/class/power_supply/max170xx_battery/uevent" cmd3 = "cat /sys/class/power_supply/intel_fuel_gauge/uevent" cmd4 = "cat /sys/class/power_supply/battery/uevent" product = self.energy.get_product() if "cht_mrd" in product: result = self.energy.testDevice.adb_cmd_capture_msg(cmd1) elif "cht_ffd" in product or "broxton" in product: result = self.energy.testDevice.adb_cmd_capture_msg(cmd2) elif "cht_cr" in product: result = self.energy.testDevice.adb_cmd_capture_msg(cmd3) else: result = self.energy.testDevice.adb_cmd_capture_msg(cmd4) #print result if "POWER_SUPPLY_NAME" not in result: assert False, "Root System permission Sysfs Failed."
def setUp(self): self._test_name = __name__ print print "[Setup]: %s" % self._test_name self.energy = Energy() self.logcat = Logcat(filter_tag="PowerManagerService", grep_opt="grep -c 'Going to sleep'")
def setUp(self): self._test_name = __name__ print "[Setup]: %s" % self._test_name self.energy = Energy() self.energy.adb_root() self.energy.set_screen_status("on") self.energy.unlock_screen()
def setUp(self): self._test_name = __name__ print "[Setup]: %s" % self._test_name self.energy = Energy() self.tmp_dir = get_tmp_dir() self.energy.set_screen_status("on") self.energy.unlock_screen() DisplaySetting().set_sleep_mode("30 minutes") super(PowerShowBatteryIcon, self).setUp()
def setUp(self): self._test_name = __name__ print "[Setup]: %s" % self._test_name self.energy = Energy() self.energy.adb_root() self.energy.set_screen_status("on") self.energy.unlock_screen() DisplaySetting().set_sleep_mode("30 minutes") #self.energy.testDevice.close_background_apps() super(Charging, self).setUp()
class PowerShowBatteryStatus(UIATestBase): def setUp(self): self._test_name = __name__ print "[Setup]: %s" % self._test_name self.energy = Energy() self.energy.adb_root() self.tmp_dir = get_tmp_dir() self.energy.set_screen_status("on") self.energy.unlock_screen() DisplaySetting().set_sleep_mode("30 minutes") super(PowerShowBatteryStatus, self).setUp() def tearDown(self): print "[Teardown]: %s" % self._test_name remove_tmp_dir(self.tmp_dir) super(PowerShowBatteryStatus, self).tearDown() def test_power_show_battery_status(self): """ Test power show battery status """ print "[RunTest]: %s" % self.__str__() uidump = os.path.join(self.tmp_dir, "uidump.xml") BatterySetting().launch() self.energy.capture_uidump_with_charging(uidump_file=uidump, charger_type=None) status = self.energy.get_battery_status_from_uidump(uidump) print status assert not ("Charging over" in status or "Full" in status)
def setUp(self): self._test_name = __name__ print "[Setup]: %s" % self._test_name self.emtools = EMToolsCharger() self.energy = Energy() self.emtools.install() self.emtools.grant_permissions() self.emtools.adb_root() self.emtools.set_screen_status("on") self.emtools.unlock_screen() DisplaySetting().set_sleep_mode("30 minutes") super(ChargerPlugUnplug, self).setUp()
class LowBatteryIcon(UIATestBase): def setUp(self): self._test_name = __name__ print "[Setup]: %s" % self._test_name self.energy = Energy() self.energy.adb_root() self.energy.set_screen_status("on") self.energy.unlock_screen() super(LowBatteryIcon, self).setUp() def tearDown(self): print "[Teardown]: %s" % self._test_name super(LowBatteryIcon, self).tearDown() def check_low_battery_icon(self, level): tmp_dir = get_tmp_dir() screenshot = os.path.join(tmp_dir, "screenshot.png") rect = Settings().get_status_bar_rect() # try 5 times retry = 5 for i in range(retry): try: self.energy.set_virtual_battery_level(level) self.energy.capture_screen(screenshot) crop_battery = CropBatteryImage(screenshot, rect) crop_battery.crop_battery() crop_battery.check_red_exclamation_in_battery_icon(True) break except Exception as e: print e.message else: assert False USBCut().cut(3) def test_battery_icon_0_percent(self): """ Check battery icon 0 percent """ print "[RunTest]: %s" % self.__str__() self.check_low_battery_icon(0) def test_battery_icon_4_percent(self): """ Check battery icon 4 percent """ print "[RunTest]: %s" % self.__str__() self.check_low_battery_icon(4)
class check_FG_driver_registration(UIATestBase): def setUp(self): self._test_name = __name__ print "[Setup]: %s" % self._test_name self.energy = Energy() def tearDown(self): print "[Teardown]: %s" % self._test_name def test_check_FG_driver_registration(self): print "[RunTest]: %s" % self.__str__() self.energy.adb_root() cmd = "ls /sys/bus/i2c/drivers/ | grep max" result = self.energy.testDevice.adb_cmd_capture_msg(cmd) if not result: assert False, "Fuel Gauger Driver Registration Not Exist."
class ScreenOffPressVolumeKey(UIATestBase): def setUp(self): self._test_name = __name__ print print "[Setup]: %s" % self._test_name self.energy = Energy() def tearDown(self): print "[Teardown]: %s" % self._test_name def test_screen_off_press_volume_key(self): """ Screen off press volume key """ print "[RunTest]: %s" % self.__str__() self.energy.set_screen_status("off") self.energy.input_keyevent("KEYCODE_VOLUME_UP") self.energy.verify_screen_status("off") self.energy.input_keyevent("KEYCODE_VOLUME_DOWN") self.energy.verify_screen_status("off")
class PowerShowBatteryIcon(UIATestBase): def setUp(self): self._test_name = __name__ print "[Setup]: %s" % self._test_name self.energy = Energy() self.tmp_dir = get_tmp_dir() self.energy.set_screen_status("on") self.energy.unlock_screen() DisplaySetting().set_sleep_mode("30 minutes") super(PowerShowBatteryIcon, self).setUp() def tearDown(self): print "[Teardown]: %s" % self._test_name remove_tmp_dir(self.tmp_dir) super(PowerShowBatteryIcon, self).tearDown() def test_power_show_battery_icon(self): """ Test power show battery icon """ print "[RunTest]: %s" % self.__str__() screenshot = os.path.join(self.tmp_dir, "screenshot.png") rect = DisplaySetting().get_status_bar_rect() self.energy.capture_screen_not_charging(screenshot) crop_battery = CropBatteryImage(screenshot, rect) crop_battery.crop_battery() crop_battery.check_charging_status_by_icon(False)
def setUp(self): self._test_name = __name__ print "[Setup]: %s" % self._test_name self.energy = Energy() self.energy.adb_root()
class ChargerPlugUnplug(UIATestBase): def setUp(self): self._test_name = __name__ print "[Setup]: %s" % self._test_name self.emtools = EMToolsCharger() self.energy = Energy() self.emtools.install() self.emtools.grant_permissions() self.emtools.adb_root() self.emtools.set_screen_status("on") self.emtools.unlock_screen() DisplaySetting().set_sleep_mode("30 minutes") super(ChargerPlugUnplug, self).setUp() def tearDown(self): print "[Teardown]: %s" % self._test_name super(ChargerPlugUnplug, self).tearDown() def check_reliability_charging(self, each_cycle, total_times, low_battery=False): if low_battery: info = self.energy.get_battery_info() assert info["level"] <= 15 cycles = total_times / len(each_cycle) pass_num = int(cycles * 0.9) result = get_charging_result(self.emtools, each_cycle, cycles) charger_types = [unit[0] for unit in each_cycle] count = {} for item in result: count[item] = count.get(item, 0) + 1 print "pass_num:", pass_num success = True for key in count.keys(): print key, count[key] if key not in charger_types: continue if count[key] < pass_num: success = False assert success # Single charging def test_SDP_plug_unplug_50_times(self): each_cycle = ((SDP, 3, 3), ) self.check_reliability_charging(each_cycle, 50) def test_SDP_plug_unplug_low_battery_50_times(self): each_cycle = ((SDP, 3, 3), ) self.check_reliability_charging(each_cycle, 50, low_battery=True) def test_CDP_plug_unplug_50_times(self): each_cycle = ((CDP, 3, 3), ) self.check_reliability_charging(each_cycle, 50) def test_CDP_plug_unplug_low_battery_50_times(self): each_cycle = ((CDP, 3, 3), ) self.check_reliability_charging(each_cycle, 50, low_battery=True) def test_DCP_plug_unplug_50_times(self): each_cycle = ((DCP, 3, 3), ) self.check_reliability_charging(each_cycle, 50) def test_DCP_plug_unplug_low_battery_50_times(self): each_cycle = ((DCP, 3, 3), ) self.check_reliability_charging(each_cycle, 50, low_battery=True) def test_DCP_slow_plug_unplug_20_times(self): each_cycle = ((DCP, 5, 5), ) self.check_reliability_charging(each_cycle, 20) def test_DCP_plug_unplug_low_battery_10_times(self): each_cycle = ((DCP, 3, 3), ) self.check_reliability_charging(each_cycle, 10, low_battery=True) def test_stress_sdp_plug_unplug(self): each_cycle = ((SDP, 3, 3), ) self.check_reliability_charging(each_cycle, 25) def test_stress_cdp_plug_unplug(self): each_cycle = ((CDP, 3, 3), ) self.check_reliability_charging(each_cycle, 25) def test_stress_CDP_plug_unplug_10_battery(self): each_cycle = ((CDP, 3, 3), ) self.check_reliability_charging(each_cycle, 25, low_battery=True) def test_stress_dcp_plug_unplug(self): each_cycle = ((DCP, 3, 3), ) self.check_reliability_charging(each_cycle, 25) # Mixed charging def test_SDP_CDP_DCP_quickly_plug_unplug_50_times(self): each_cycle = ((DCP, 3, 3), (CDP, 3, 3), (SDP, 3, 3)) self.check_reliability_charging(each_cycle, 50) def test_SDP_CDP_DCP_plug_unplug_50_times_low_battery(self): each_cycle = ((DCP, 3, 3), (CDP, 3, 3), (SDP, 3, 3)) self.check_reliability_charging(each_cycle, 50, low_battery=True) def test_SDP_CDP_quickly_plug_unplug_50_times(self): each_cycle = ((CDP, 3, 3), (SDP, 3, 3)) self.check_reliability_charging(each_cycle, 50) def test_SDP_CDP_slow_plug_unplug_20_times(self): each_cycle = ((CDP, 5, 5), (SDP, 5, 5)) self.check_reliability_charging(each_cycle, 20) def test_SDP_DCP_quickly_plug_unplug_50_times(self): each_cycle = ((DCP, 3, 3), (SDP, 3, 3)) self.check_reliability_charging(each_cycle, 50) def test_CDP_DCP_quickly_plug_unplug_50_times(self): each_cycle = ((DCP, 3, 3), (CDP, 3, 3)) self.check_reliability_charging(each_cycle, 50) # charger plug unplug in sleep def check_plug_unplug_in_sleep(self, each_cycle, total_times): cycles = total_times / len(each_cycle) pass_num = int(total_times * 2) result = get_charging_result(EMToolsScreen(), each_cycle, cycles) screen_on_count = result.count("ON") print "pass_num:", pass_num print "screen on count:", screen_on_count assert screen_on_count >= pass_num def test_SDP_plug_unplug_in_sleep(self): each_cycle = ((SDP, 20, 20), ) self.check_plug_unplug_in_sleep(each_cycle, 50) def test_CDP_plug_unplug_in_sleep(self): each_cycle = ((CDP, 20, 20), ) self.check_plug_unplug_in_sleep(each_cycle, 50) def test_DCP_plug_unplug_in_sleep(self): each_cycle = ((DCP, 20, 20), ) self.check_plug_unplug_in_sleep(each_cycle, 50)
def test_SDP_less_than_15_pattern_lockscreen(self): from testlib.em.screen_lock import CPattern self.encrypt = CPattern() info = Energy().get_battery_info() assert info["level"] <= 15 self.verify_charging_info_in_lockscreen()
class Charging(UIATestBase): def setUp(self): self._test_name = __name__ print "[Setup]: %s" % self._test_name self.energy = Energy() self.energy.adb_root() self.energy.set_screen_status("on") self.energy.unlock_screen() DisplaySetting().set_sleep_mode("30 minutes") #self.energy.testDevice.close_background_apps() super(Charging, self).setUp() def tearDown(self): print "[Teardown]: %s" % self._test_name def check_screen_off_connect_charger(self, each_cycle): from testlib.em.apps import EMToolsScreen from testlib.em.charging import get_charging_result emtools = EMToolsScreen() emtools.install() hist = get_charging_result(emtools, each_cycle, 1) assert hist.count("ON") == 3 def test_screen_off_connect_SDP_charger(self): """ Screen off connect SDP charger """ print "[RunTest]: %s" % self.__str__() each_cycle = ((SDP, 20, 20), ) self.check_screen_off_connect_charger(each_cycle) def test_screen_off_connect_CDP_charger(self): """ Screen off connect CDP charger """ print "[RunTest]: %s" % self.__str__() each_cycle = ((CDP, 20, 20), ) self.check_screen_off_connect_charger(each_cycle) def test_screen_off_connect_DCP_charger(self): """ Screen off connect DCP charger """ print "[RunTest]: %s" % self.__str__() each_cycle = ((DCP, 20, 20), ) self.check_screen_off_connect_charger(each_cycle) def test_screen_off_connect_hub_charger(self): """ Screen off connect HUB charger(SDP hub) """ print "[RunTest]: %s" % self.__str__() each_cycle = ((SDP, 20, 20), ) self.check_screen_off_connect_charger(each_cycle) def test_screen_wake_after_usb_plugged(self): """ Screen wake after usb plugged """ print "[RunTest]: %s" % self.__str__() from testlib.em.basic_ui import LockScreenUI from testlib.em.crop_battery_icon import CropBatteryImage from testlib.em.tools import get_tmp_dir, remove_tmp_dir from testlib.em.usb_cut import USBCut lockscreen = LockScreenUI() lockscreen.lock_screen() USBCut().cut(20) assert self.energy.get_screen_status() tmp_dir = get_tmp_dir() screenshot = os.path.join(tmp_dir, "screenshot.png") rect = lockscreen.get_battery_icon_rect() self.energy.set_screen_status("on") time.sleep(2) self.energy.capture_screen(screenshot) crop_battery = CropBatteryImage(screenshot, rect) crop_battery.check_charging_status_by_icon(True) remove_tmp_dir(tmp_dir) time.sleep(20) self.energy.verify_screen_status("off") def test_sdp_charger_insertion_when_device_on(self): """ SDP charger insertion when device is on """ print "[RunTest]: %s" % self.__str__() from testlib.em.tools import get_tmp_dir, remove_tmp_dir from testlib.em.crop_battery_icon import CropBatteryImage rect = BatterySetting().get_status_bar_rect() tmp_dir = get_tmp_dir() screenshot = os.path.join(tmp_dir, "screenshot.png") self.energy.capture_screen(screenshot) crop_battery = CropBatteryImage(screenshot, rect) crop_battery.check_charging_status_by_icon(True) remove_tmp_dir(tmp_dir) def test_charged_by_usb_cable(self): """ Test charged by usb cable """ print "[RunTest]: %s" % self.__str__() battery = BatterySetting() battery.launch() status = battery.get_battery_status() print status assert "USB" in status def test_power_show_charging_icon(self): """ Test power show charging icon """ print "[RunTest]: %s" % self.__str__() from testlib.em.tools import get_tmp_dir, remove_tmp_dir from testlib.em.crop_battery_icon import CropBatteryImage import os tmp_dir = get_tmp_dir() screenshot = os.path.join(tmp_dir, "screenshot.png") rect = DisplaySetting().get_status_bar_rect() self.energy.capture_screen(screenshot) crop_battery = CropBatteryImage(screenshot, rect) crop_battery.crop_battery() crop_battery.check_charging_status_by_icon(True) remove_tmp_dir(tmp_dir) def test_power_show_charging_status(self): """ Test power show charging status """ print "[RunTest]: %s" % self.__str__() battery = BatterySetting() status = battery.get_battery_status() if "Full" in status: return assert "Charging" in status def test_power_show_charging_percentage(self): """ Test power show charging percentage """ print "[RunTest]: %s" % self.__str__() level1 = self.energy.get_battery_info()["level"] self.energy.set_screen_status("off") for i in range(100): print "cycle:", i + 1 level2 = self.energy.get_battery_info()["level"] if level2 > level1: return time.sleep(60) self.energy.set_screen_status("on") self.energy.unlock_screen() level2 = self.energy.get_battery_info()["level"] assert level2 > level1 def test_SDP_charging(self): """ SDP charging """ print "[RunTest]: %s" % self.__str__() battery = BatterySetting() status = battery.get_battery_status() if "Full" in status: return assert "USB" in status def test_DCP_charging(self): """ DCP charging """ print "[RunTest]: %s" % self.__str__() from testlib.em.apps import EMToolsCharger from testlib.em.charging import get_charging_result each_cycle = ((DCP, 2, 2), ) hist = get_charging_result(EMToolsCharger(), each_cycle, 1) print hist assert DCP in hist def test_CDP_charging(self): """ CDP charging """ print "[RunTest]: %s" % self.__str__() from testlib.em.apps import EMToolsCharger from testlib.em.charging import get_charging_result each_cycle = ((CDP, 2, 2), ) hist = get_charging_result(EMToolsCharger(), each_cycle, 1) print hist assert CDP in hist def test_check_AC_charger(self): """ to check AC charger/ Wall charger current value """ print "[RunTest]: %s" % self.__str__() from testlib.em.apps import EMToolsCharger from testlib.em.charging import get_charging_result each_cycle = ((DCP, 2, 2), ) hist = get_charging_result(EMToolsCharger(), each_cycle, 1) print hist assert DCP in hist
def test_SDP_more_than_15_pin_lockscreen(self): from testlib.em.screen_lock import CPIN self.encrypt = CPIN() info = Energy().get_battery_info() assert info["level"] > 15 self.verify_charging_info_in_lockscreen()
def test_SDP_more_than_15_swipe_lockscreen(self): info = Energy().get_battery_info() assert info["level"] > 15 self.screen.lock_screen() status = self.screen.get_charging_status() assert status
class BatteryLevelVoltage(UIATestBase): def setUp(self): self._test_name = __name__ print "[Setup]: %s" % self._test_name self.energy = Energy() self.energy.adb_root() self.energy.set_screen_status("on") self.energy.unlock_screen() def tearDown(self): print "[Teardown]: %s" % self._test_name def test_battery_level_at_voltage_3_6(self): """ Test battery level at voltage 3.6V """ print "[RunTest]: %s" % self.__str__() verify_level_voltage_match(3, 3600) def test_battery_level_at_voltage_3_7(self): """ Test battery level at voltage 3.7V """ print "[RunTest]: %s" % self.__str__() verify_level_voltage_match(15, 3700) def test_battery_level_at_voltage_3_8(self): """ Test battery level at voltage 3.8V """ print "[RunTest]: %s" % self.__str__() verify_level_voltage_match(38, 3800) def test_battery_level_at_voltage_3_9(self): """ Test battery level at voltage 3.9V """ print "[RunTest]: %s" % self.__str__() verify_level_voltage_match(57, 3900) def test_battery_level_at_voltage_4_0(self): """ Test battery level at voltage 4.0V """ print "[RunTest]: %s" % self.__str__() verify_level_voltage_match(68, 4000) def test_battery_level_at_voltage_4_1(self): """ Test battery level at voltage 4.1V """ print "[RunTest]: %s" % self.__str__() verify_level_voltage_match(80, 4100) def test_battery_level_at_voltage_4_2(self): """ Test battery level at voltage 4.2V """ print "[RunTest]: %s" % self.__str__() verify_level_voltage_match(90, 4200) def test_battery_level_at_voltage_4_3(self): """ Test battery level at voltage 4.3V """ print "[RunTest]: %s" % self.__str__() verify_level_voltage_match(98, 4300)