Exemple #1
0
    def test_210_tns_preview_on_simulator_and_emulator_livesync(self):
        """
        Preview app on simulator and emulator. Verify livesync.
        """
        # Preview on emulator
        result = Tns.preview(app_name=self.app_name)

        # Read the log and extract the url to load the app on emulator
        log = File.read(result.log_file)
        url = Preview.get_url(log)
        Preview.run_url(url=url, device=self.emu)
        strings = TnsLogs.preview_initial_messages(platform=Platform.ANDROID)
        TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings)
        self.emu.wait_for_text(text=Changes.JSHelloWord.JS.old_text)

        # Click on TAP button on emulator
        Adb.click_element_by_text(self.emu.id, 'TAP', case_sensitive=True)

        # Preview on simulator
        Preview.run_url(url=url, device=self.sim)
        strings = TnsLogs.preview_initial_messages(platform=Platform.IOS)
        TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings)
        self.sim.wait_for_text(text=Changes.JSHelloWord.JS.old_text)

        # Verify emulator is not refreshed, state of app is preserved
        self.emu.wait_for_text(text='41 taps left', timeout=30)

        # Edit JS file and verify changes are applied on both emulators
        Sync.replace(app_name=self.app_name, change_set=Changes.JSHelloWord.JS)
        self.emu.wait_for_text(text=Changes.JSHelloWord.JS.new_text)
        self.sim.wait_for_text(text=Changes.JSHelloWord.JS.new_text)

        # Check changes are not synced more than once per platform
        # Extract the last part of the log
        log = File.read(result.log_file)
        log = File.extract_part_of_text(log, '[VERIFIED]')
        # Verify files are synced once
        TnsAssert.file_is_synced_once(log, Platform.ANDROID,
                                      'main-view-model.js')
        TnsAssert.file_is_synced_once(log, Platform.IOS, 'main-view-model.js')
        # Mark that part of the log as verified before next sync
        File.append(result.log_file, '[VERIFIED]')

        # Edit XML file and verify changes are applied on both emulators
        Sync.replace(app_name=self.app_name,
                     change_set=Changes.JSHelloWord.XML)
        self.emu.wait_for_text(text=Changes.JSHelloWord.XML.new_text)
        self.sim.wait_for_text(text=Changes.JSHelloWord.XML.new_text)

        # Check changes are not synced more than once per platform
        # Extract the last part of the log
        log = File.read(result.log_file)
        log = File.extract_part_of_text(log, '[VERIFIED]')
        # Verify files are synced once
        TnsAssert.file_is_synced_once(log, Platform.ANDROID, 'main-page.xml')
        TnsAssert.file_is_synced_once(log, Platform.IOS, 'main-page.xml')
    def run_app(app_name,
                platform,
                device,
                bundle=True,
                hmr=True,
                instrumented=False,
                click_open_alert=False):
        result = Tns.preview(app_name=app_name, bundle=bundle, hmr=hmr)

        # Read the log and extract the url to load the app on emulator
        log = File.read(result.log_file)
        url = Preview.get_url(log)
        Preview.run_url(url=url, device=device)
        # When you run preview on ios simulator on first run confirmation dialog is shown.
        if device.type == DeviceType.SIM:
            if click_open_alert is True:
                if SimAuto.find(device_info=device, text="Open"):
                    time.sleep(5)
                    device.click("Open")

        # Verify logs
        strings = TnsLogs.preview_initial_messages(platform=platform,
                                                   hmr=hmr,
                                                   bundle=bundle,
                                                   instrumented=instrumented)
        TnsLogs.wait_for_log(log_file=result.log_file,
                             string_list=strings,
                             timeout=100)
        return result
Exemple #3
0
    def test_210_tns_preview_android_livesync_on_two_emulators(self):
        """
        Test when preview on second emulator only the current one is refreshed.
        Test changes are synced on both emulators.
        """
        # Preview on emulator
        result = Tns.preview(app_name=self.app_name)

        # Read the log and extract the url to load the app on emulator
        log = File.read(result.log_file)
        url = Preview.get_url(log)
        Preview.run_url(url=url, device=self.emu)
        strings = TnsLogs.preview_initial_messages(device=self.emu)
        TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings)
        self.emu.wait_for_text(text=Changes.JSHelloWord.JS.old_text,
                               timeout=120)

        # Click on TAP button on emulator
        Adb.click_element_by_text(self.emu.id, 'TAP', case_sensitive=True)

        # Preview on second emulator
        Preview.run_url(url=url, device=self.emu_API24)
        # Here use bundle=False because on consecutive preview build is not executed again
        # and no bundle messages are displayed in log
        strings = TnsLogs.preview_initial_messages(device=self.emu,
                                                   bundle=False)
        TnsLogs.wait_for_log(log_file=result.log_file,
                             string_list=strings,
                             timeout=120)
        self.emu_API24.wait_for_text(text=Changes.JSHelloWord.JS.old_text)

        # Verify first emulator is not refreshed, state of app is preserved
        self.emu.wait_for_text(text='41 taps left', timeout=30)

        # Edit JS file and verify changes are applied on both emulators
        Sync.replace(app_name=self.app_name, change_set=Changes.JSHelloWord.JS)
        self.emu.wait_for_text(text=Changes.JSHelloWord.JS.new_text)
        self.emu_API24.wait_for_text(text=Changes.JSHelloWord.JS.new_text)

        # Edit XML file and verify changes are applied
        Sync.replace(app_name=self.app_name,
                     change_set=Changes.JSHelloWord.XML)
        self.emu.wait_for_text(text=Changes.JSHelloWord.XML.new_text)
        self.emu_API24.wait_for_text(text=Changes.JSHelloWord.XML.new_text)
    def test_210_tns_preview_on_simulator_and_emulator_livesync(self):
        """
        Preview app on simulator and emulator. Verify livesync.
        """
        # Preview on emulator
        result = Tns.preview(app_name=self.app_name)

        # Read the log and extract the url to load the app on emulator
        log = File.read(result.log_file)
        url = Preview.get_url(log)
        Preview.run_url(url=url, device=self.emu)
        strings = TnsLogs.preview_initial_messages(platform=Platform.ANDROID)
        TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings)
        self.emu.wait_for_text(text=Changes.JSHelloWord.JS.old_text)

        # Click on TAP button on emulator
        Adb.click_element_by_text(self.emu.id, 'TAP', case_sensitive=True)

        # Preview on simulator
        Preview.run_url(url=url, device=self.sim)
        strings = TnsLogs.preview_initial_messages(platform=Platform.IOS)
        TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings)
        self.sim.wait_for_text(text=Changes.JSHelloWord.JS.old_text)

        # Verify emulator is not refreshed, state of app is preserved
        self.emu.wait_for_text(text='41 taps left', timeout=30)

        # Edit JS file and verify changes are applied on both emulators
        Sync.replace(app_name=self.app_name, change_set=Changes.JSHelloWord.JS)
        self.emu.wait_for_text(text=Changes.JSHelloWord.JS.new_text)
        self.sim.wait_for_text(text=Changes.JSHelloWord.JS.new_text)

        # Edit XML file and verify changes are applied
        Sync.replace(app_name=self.app_name,
                     change_set=Changes.JSHelloWord.XML)
        self.emu.wait_for_text(text=Changes.JSHelloWord.XML.new_text)
        self.sim.wait_for_text(text=Changes.JSHelloWord.XML.new_text)