コード例 #1
0
class check_FG_interrupt_registration(UIATestBase):
    def setUp(self):
        self._test_name = __name__
        print "[Setup]: %s" % self._test_name
        self.emImpl = EMImpl()

    def tearDown(self):
        print "[Teardown]: %s" % self._test_name

    def test_check_FG_interrupt_registration(self):

        print "[RunTest]: %s" % self.__str__()
        self.emImpl.adb_root()
        time.sleep(2)
        self.emImpl.adb_root()
        time.sleep(5)
        product = self.emImpl.product
        if "cht_ffd" in product:
            cmd = "cat /proc/interrupts | grep max17"
            result = g_common_obj.adb_cmd_capture_msg(cmd)
            if not result:
                assert False, "Fuel Gauger Interrupt Registration Not Exist."
        else:
            assert False, "Not applicable for this DUT"
コード例 #2
0
class BatterySaver(UIATestBase):
    def setUp(self):
        self._test_name = __name__
        print "[Setup]: %s" % self._test_name
        self.emImpl = EMImpl()
        self.emImpl.adb_root()
        self.result_dir = self.emImpl.get_tmp_dir()
        self.wait_time = int(
            self.emImpl.get_config_value("battery_saver", "wait_time"))
        self.emImpl.set_screen_status("on")
        self.emImpl.unlock_screen()
        self.emImpl.setSleepMode("30 minutes")
        self.emImpl.set_brightness_level(255)
        g_common_obj.close_background_apps()
        super(BatterySaver, self).setUp()

    def tearDown(self):
        print "[Teardown]: %s" % self._test_name
        self.emImpl.check_adb_or_reconnect()
        self.emImpl.remove_tmp_dir(self.result_dir)
        super(BatterySaver, self).tearDown()

    def check_battery_history(self, name=None, data=None):
        # connect WIFI_ADB
        ssid, passwd = self.emImpl.read_wifi_conf()
        self.emImpl.connect_wifi(ssid, passwd)
        wifi_serial = self.emImpl.enable_wifi_adb()
        self.emImpl_wifi = EMImpl(wifi_serial)

        self.emImpl.enable_full_wake_history()
        self.emImpl.reset_batterystats()
        self.emImpl.launch_settings("Battery saver")
        self.emImpl.disconnect_adb()
        self.emImpl_wifi.open_battery_saver()

        if name == "record_video":
            self.emImpl_wifi.grant_permissions_for_camera_app()
            self.emImpl_wifi.launch_camera("Video")
            self.emImpl_wifi.click_shutter_button()
        elif name == "chrome":
            self.emImpl_wifi.chrome_open_url(data)
            if data.endswith("mp3"):
                self.emImpl_wifi.play_audio_chrome()
            elif data.endswith("mp4"):
                self.emImpl_wifi.play_video_chrome()
        elif name == "audio":
            self.emImpl_wifi.play_media_file("audio/*", data)
        elif name == "video":
            self.emImpl_wifi.play_media_file("video/*", data)
        elif name == "templerun":
            self.emImpl_wifi.launch_templerun()
            time.sleep(60)
            self.emImpl_wifi.play_templerun()
        elif name == "glbenchmark":
            self.emImpl_wifi.run_glbenchmark27()

        time.sleep(self.wait_time)
        self.emImpl.connect_adb()

        bugreport_file = self.emImpl.save_bugreport(self.result_dir)
        html_file = self.emImpl.generate_battery_history_html(bugreport_file)
        self.emImpl.parse_battery_history_html(html_file)

    def test_battery_life_compared_record_video(self):
        """
        Test battery life compared record 1080P video max backlight
        """
        print "[RunTest]: %s" % self.__str__()
        self.check_battery_history(name="record_video")

    def test_battery_life_compared_chrome_web_browser(self):
        """
        Test battery life compared chrome web browser
        """
        print "[RunTest]: %s" % self.__str__()
        url = "http://" + self.emImpl.get_server_ip(
        ) + self.emImpl.get_config_value("webpage", "webgl")
        self.check_battery_history(name="chrome", data=url)

    def test_battery_life_compared_chrome_audio_play(self):
        """
        Test battery life compared chrome audio play
        """
        print "[RunTest]: %s" % self.__str__()
        self.emImpl.close_chrome_tabs()
        url = "http://" + self.emImpl.get_server_ip(
        ) + self.emImpl.get_config_value("webpage", "audio_play")
        self.check_battery_history(name="chrome", data=url)

    def test_battery_life_compared_chrome_video_play(self):
        """
        Test battery life compared chrome video play
        """
        print "[RunTest]: %s" % self.__str__()
        self.emImpl.close_chrome_tabs()
        url = "http://" + self.emImpl.get_server_ip(
        ) + self.emImpl.get_config_value("webpage", "video_play")
        self.check_battery_history(name="chrome", data=url)

    def test_battery_life_compared_audio_play(self):
        """
        Test battery life compared audio play
        """
        print "[RunTest]: %s" % self.__str__()
        self.emImpl.grant_music_app_permissions()
        music_file = self.emImpl.push_artifactory_resource(
            "long_music", "/mnt/sdcard/Music")
        self.check_battery_history(name="audio", data="file://" + music_file)

    def test_battery_life_compared_video_play(self):
        """
        Test battery life compared video play
        """
        print "[RunTest]: %s" % self.__str__()
        video_file = self.emImpl.push_artifactory_resource(
            "video", "/mnt/sdcard/Movies")
        self.check_battery_history(name="video", data="file://" + video_file)

    def test_battery_life_compared_play_3D_game(self):
        """
        Test battery life compared play 3D game
        """
        print "[RunTest]: %s" % self.__str__()
        temple_run_package = "com.imangi.templerun2"
        self.emImpl.install_artifactory_app("templerun", temple_run_package)
        self.check_battery_history(name="templerun")

    def test_battery_historian_tool(self):
        """
        Test battery historian tool
        """
        print "[RunTest]: %s" % self.__str__()
        self.check_battery_history()

    def test_battery_life_compared_glbenchmark27(self):
        """
        Test battery life compared glbenchmark27
        """
        print "[RunTest]: %s" % self.__str__()
        app_package = 'com.glbenchmark.glbenchmark27'
        self.emImpl.install_artifactory_app("glbenchmark", app_package)
        self.check_battery_history(name="glbenchmark")
コード例 #3
0
class ChargerWakeupSystem(UIATestBase):
    def setUp(self):
        self._test_name = __name__
        print "[Setup]: %s" % self._test_name
        self.emImpl = EMImpl()
        self.suspend_time = int(self.emImpl.get_config_value("s0ix", "suspend_time"))
        self.emImpl.adb_root()
        self.emImpl.set_screen_status("on")
        self.emImpl.unlock_screen()
        self.emImpl.setSleepMode("30 minutes")
        self.emImpl.install_em_tools()
        super(ChargerWakeupSystem, self).setUp()

    def tearDown(self):
        print "[Teardown]: %s" % self._test_name
        self.emImpl.three_way_cutter_reconnect_sdp(3, 2, 5)
        super(ChargerWakeupSystem, self).tearDown()

    def charger_wakeup_system_in_S0i3(self, charger_type):
        s3_pre = self.emImpl.get_s0i3_suspend_stat()
        self.emImpl.set_screen_status("on")
        self.emImpl.unlock_screen()
        self.emImpl.start_monitor_screen_on_off()
        self.emImpl.set_screen_status("off")
        time.sleep(2)
        if charger_type == SDP:
            self.emImpl.enable_sdp_charging(self.suspend_time, 5)
        elif charger_type == CDP:
            self.emImpl.enable_cdp_charging(self.suspend_time, 5)
        else:
            self.emImpl.enable_dcp_charging(self.suspend_time, 5)
        # wait screen off
        time.sleep(15)
        self.emImpl.three_way_cutter_reconnect_sdp(3, 2, 5)
        self.emImpl.unlock_screen()
        history = self.emImpl.get_screen_on_off_history().split()
        result = True
        if history.count("ON") < 3:
            result = False
        if history.count("OFF") < 3:
            result = False
        s3_post = self.emImpl.get_s0i3_suspend_stat()
        if s3_pre == s3_post:
            result = False
        return result

    def test_DCP_wakeup_system_in_S0i3(self):
        print "[RunTest]: %s" % self.__str__()
        assert self.charger_wakeup_system_in_S0i3(DCP)

    def test_DCP_wakeup_system_in_s0i3_10_times(self):
        print "[RunTest]: %s" % self.__str__()
        fail_num = 0
        cycles = 10
        for i in range(1, 1 + cycles):
            print "[info]--- Cycle: %s/%s" % (i, cycles)
            if not self.charger_wakeup_system_in_S0i3(DCP):
                fail_num += 1
            assert fail_num <= 2, "Failed times: %s" % fail_num

    def test_SDP_CDP_wakeup_system_in_s0i3_10_times(self):
        print "[RunTest]: %s" % self.__str__()
        fail_num = 0
        cycles = 10
        chargers = [SDP, CDP]
        for i in range(1, 1 + cycles):
            print "[info]--- Cycle: %s/%s" % (i, cycles)
            if not self.charger_wakeup_system_in_S0i3(chargers[i % 2]):
                fail_num += 1
            assert fail_num <= 2, "Failed times: %s" % fail_num
コード例 #4
0
class ChargingLongTime(UIATestBase):
    """
    Connecting CDP charger in MOS and wait one night for 12 hours, check battery increase.
    """
    def setUp(self):
        self._test_name = __name__
        print "[Setup]: %s" % self._test_name
        self.emImpl = EMImpl()
        self.emImpl.set_screen_status("on")
        self.emImpl.unlock_screen()
        g_common_obj.close_background_apps()
        super(ChargingLongTime, self).setUp()

    def tearDown(self):
        super(ChargingLongTime, self).tearDown()
        print "[Teardown]: %s" % self._test_name

    def check_charging_12h(self, charger_type, device_mode=MOS):
        level = self.emImpl.get_battery_level()
        if device_mode == COS:
            self.emImpl.power_off_device()
        else:
            self.emImpl.set_screen_status("off")
            time.sleep(5)
        # charge 12h
        if charger_type == CDP:
            self.emImpl.enable_cdp_charging()
        elif charger_type == DCP:
            self.emImpl.enable_dcp_charging()
        print "Sleep 12h."
        time.sleep(12 * 3600)
        if charger_type != SDP:
            self.emImpl.enable_sdp_charging()
            time.sleep(30)

        if device_mode == COS:
            self.emImpl.boot_up_device()
            self.emImpl.adb_root()
        level = self.emImpl.get_battery_level()
        assert level >= FULL, "charging for 12 hours is not full."

    def check_charging_1h(self, charger_type):
        level1 = self.emImpl.get_battery_level()
        self.emImpl.set_screen_status("off")
        time.sleep(5)
        if charger_type == CDP:
            self.emImpl.enable_cdp_charging()
        elif charger_type == DCP:
            self.emImpl.enable_dcp_charging()
        print "Sleep 1h."
        time.sleep(36)
        if charger_type != SDP:
            self.emImpl.enable_sdp_charging()
        level2 = self.emImpl.get_battery_level()
        assert level2 >= min(FULL, level1 + 10)

    def test_charging_CDP_MOS_12_hours(self):
        self.check_charging_12h(CDP, MOS)

    def test_charging_CDP_COS_12_hours(self):
        self.check_charging_12h(CDP, COS)

    def test_charging_DCP_MOS_12_hours(self):
        self.check_charging_12h(DCP, MOS)

    def test_charging_DCP_COS_12_hours(self):
        self.check_charging_12h(DCP, COS)

    def test_charging_SDP_MOS_12_hours(self):
        self.check_charging_12h(SDP, MOS)

    def test_charging_SDP_COS_12_hours(self):
        self.check_charging_12h(SDP, COS)

    def test_CDP_charging_1_hour(self):
        self.check_charging_1h(CDP)

    def test_DCP_charging_1_hour(self):
        self.check_charging_1h(DCP)

    def test_SDP_charging_1_hour(self):
        self.check_charging_1h(SDP)
コード例 #5
0
class SDP_Low_Battery(UIATestBase):
    def setUp(self):
        self._test_name = __name__
        print "[Setup]: %s" % self._test_name
        self.emImpl = EMImpl()
        assert self.emImpl.get_battery_level() <= 15
        self.emImpl.adb_root()
        self.emImpl.set_screen_status("on")
        self.emImpl.unlock_screen()
        self.emImpl.setSleepMode("30 minutes")
        super(SDP_Low_Battery, self).setUp()

    def tearDown(self):
        print "[Teardown]: %s" % self._test_name
        self.emImpl.stop_focused_activity()

    def test_SDP_playing_music_low_battery(self):
        self.emImpl.grant_music_app_permissions()
        audio_file = self.emImpl.push_artifactory_resource(
            "long_music", "/mnt/sdcard/Music")
        self.emImpl.play_media_file("audio/*", "file://" + audio_file)
        time.sleep(5)
        assert self.emImpl.get_sdp_charge_status()

    def test_SDP_playing_video_low_battery(self):
        video_file = self.emImpl.push_artifactory_resource(
            "video", "/mnt/sdcard/Movies")
        self.emImpl.play_media_file("video/*", "file://" + video_file)
        time.sleep(5)
        assert self.emImpl.get_sdp_charge_status()

    def test_SDP_plug_unplug_low_battery(self):
        cycles = 10
        for i in range(1, 1 + cycles):
            print "[info]--- Cycles: %s/%s" % (i, cycles)
            self.emImpl.set_three_way_cutter_usb(0)
            time.sleep(2)
            self.emImpl.set_three_way_cutter_usb(1)
            time.sleep(5)
            assert self.emImpl.get_sdp_charge_status()

    def test_SDP_surfing_internet_low_battery(self):
        ssid, passwd = self.emImpl.read_wifi_conf()
        self.emImpl.connect_wifi(ssid, passwd)
        self.webpage = "http://" + self.emImpl.get_server_ip(
        ) + self.emImpl.get_config_value("webpage", "simple_page")
        self.emImpl.close_chrome_tabs()
        self.emImpl.chrome_open_url(self.webpage)
        time.sleep(5)
        assert self.emImpl.get_sdp_charge_status()

    def test_SDP_taking_image_low_battery(self):
        self.emImpl.grant_permissions_for_camera_app()
        self.emImpl.launch_camera()
        self.emImpl.click_shutter_button()
        time.sleep(5)
        assert self.emImpl.get_sdp_charge_status()

    def test_SDP_taking_videorecord_low_battery(self):
        self.emImpl.grant_permissions_for_camera_app()
        self.emImpl.launch_camera("Video")
        self.emImpl.click_shutter_button("Video")
        time.sleep(5)
        assert self.emImpl.get_sdp_charge_status()
コード例 #6
0
class LowBatteryPerformance(UIATestBase):
    def setUp(self):
        self._test_name = __name__
        print "[Setup]: %s" % self._test_name
        self.emImpl = EMImpl()
        self.emImpl.adb_root()
        self.emImpl.set_screen_status("on")
        self.emImpl.unlock_screen()
        self.emImpl.set_sleep_mode("30 minutes")
        self.enable_wifi_adb()
        super(LowBatteryPerformance, self).setUp()

    def tearDown(self):
        print "[Teardown]: %s" % self._test_name
        self.emImpl.three_way_cutter_reconnect_sdp(3, 2, 5)
        super(LowBatteryPerformance, self).tearDown()

    def enable_wifi_adb(self):
        ssid, passwd = self.emImpl.read_wifi_conf()
        self.emImpl.connect_wifi(ssid, passwd)
        serial_wifi = self.emImpl.enable_wifi_adb()
        self.emImpl_wifi = EMImpl(serial_wifi)

    def prepare_battery_level(self, target_level):
        actual_level = self.emImpl.get_battery_level()
        if actual_level < target_level - 1:
            self.emImpl.set_screen_status("off")
            self.emImpl.enable_dcp_charging(2, 2)
            cycles = 20
            for i in range(1, 1 + cycles):
                wait_time = 60 * (target_level - actual_level)
                print "Cycle: %d/%d, wait %ds" % (i, cycles, wait_time)
                time.sleep(wait_time)
                actual_level = self.emImpl_wifi.get_battery_level()
                if actual_level >= target_level:
                    break
            else:
                assert False
            self.emImpl.three_way_cutter_reconnect_sdp(3, 2, 5)
            self.emImpl.set_screen_status("on")
            self.emImpl.unlock_screen()

        elif actual_level > target_level + 1:
            video_file = self.emImpl.push_artifactory_resource(
                "video", "/mnt/sdcard/Movies")
            self.emImpl.play_media_file("video/*", "file://" + video_file)
            time.sleep(5)
            self.emImpl.set_three_way_cutter_usb(0)
            cycles = 20
            for i in range(1, 1 + cycles):
                wait_time = 60 * (actual_level - target_level)
                print "Cycle: %d/%d, wait %ds" % (i, cycles, wait_time)
                time.sleep(wait_time)
                actual_level = self.emImpl_wifi.get_battery_level()
                if actual_level <= target_level:
                    break
            else:
                assert False
            self.emImpl.three_way_cutter_reconnect_sdp(3, 2, 5)
            self.emImpl.stop_focused_activity()

    def check_low_battery_warning(self, low_level):
        cycles = 20
        for i in range(1, 1 + cycles):
            print "Check low battery warning: %d/%d" % (i, cycles)
            time.sleep(60)
            if self.emImpl_wifi.get_battery_level() <= low_level:
                break
        else:
            assert False, "battery level higher than 15%"
        assert self.emImpl_wifi.check_lowbattery_notification()

    def test_low_battery_warning_15_play_video(self):
        """
        Test low battery warning 15% play video
        """
        print "[RunTest]: %s" % self.__str__()
        self.prepare_battery_level(17)
        video_file = self.emImpl.push_artifactory_resource(
            "video", "/mnt/sdcard/Movies")
        self.emImpl.play_media_file("video/*", "file://" + video_file)
        time.sleep(5)
        self.emImpl.set_three_way_cutter_usb(0)
        self.check_low_battery_warning(15)
        self.emImpl.stop_focused_activity()

    def test_low_battery_warning_15(self):
        """
        Test low battery warning 15
        """
        print "[RunTest]: %s" % self.__str__()
        self.prepare_battery_level(17)
        self.emImpl.set_three_way_cutter_usb(0)
        self.check_low_battery_warning(15)

    def test_low_battery_warning_5(self):
        """
        Test low battery warning 5
        """
        print "[RunTest]: %s" % self.__str__()
        self.prepare_battery_level(7)
        self.emImpl.set_three_way_cutter_usb(0)
        time.sleep(5)
        self.emImpl_wifi.clean_notification()
        self.check_low_battery_warning(5)

    def test_battery_20_discharge_util_shutdown(self):
        print "[RunTest]: %s" % self.__str__()
        self.prepare_battery_level(20)
        video_file = self.emImpl.push_artifactory_resource(
            "video", "/mnt/sdcard/Movies")
        self.emImpl.play_media_file("video/*", "file://" + video_file)
        time.sleep(5)
        self.emImpl.set_three_way_cutter_usb(0)
        for _ in range(20):
            if not self.emImpl_wifi.get_state():
                break
            try:
                level = self.emImpl_wifi.get_battery_level()
            except:
                break
            wait_time = 60 * level + 5
            print "Wait %ds" % wait_time
            time.sleep(wait_time)
        else:
            assert False
        self.emImpl.enable_dcp_charging(2, 2)
        time.sleep(600)
        self.emImpl.enable_sdp_charging(2, 2)
        time.sleep(60)
        self.emImpl.boot_up_device()
        self.emImpl.adb_root()