Exemplo n.º 1
0
    def test_move_file(self, driver):
        Actions.clickButtonXP(self, driver, Locators.MENU_BUTTON_XP)
        Actions.clickButtonXP(self, driver, Locators.PICTURES_BUTTON_XP)
        Actions.clickButtonXP(self, driver, Locators.SUBMENU_BUTTON_XP)
        Actions.clickButtonXP(self, driver, Locators.SELECT_ALL_BUTTON_XP)

        count_on_pictures_page_before = Actions.count_of_all_selected(self, driver)

        Actions.clickButtonXP(self, driver, Locators.BACK_BUTTON_IF_SELECTED_XP)
        Actions.clickButtonXP(self, driver, Locators.MENU_BUTTON_XP)
        Actions.clickButtonXP(self, driver, Locators.CAMERA_BUTTON_XP)

        Actions.longtap(self, driver, Locators.FIRST_FILE_FOLDER_XP)
        Actions.clickButtonXP(self, driver, Locators.SUBMENU_BUTTON_XP)
        Actions.clickButtonXP(self, driver, Locators.MOVE_BUTTON_XP)
        Actions.clickButtonID(self, driver, Locators.CANCEL_MOVE_BUTTON_ID)

        assert Actions.isObjectExistsID(self, driver, Locators.IS_SELECTED_FILE_ID) == False

        Actions.longtap(self, driver, Locators.FIRST_FILE_FOLDER_XP)
        Actions.clickButtonXP(self, driver, Locators.SUBMENU_BUTTON_XP)
        Actions.clickButtonXP(self, driver, Locators.MOVE_BUTTON_XP)
        Actions.clickButtonXP(self, driver, Locators.MENU_BUTTON_XP)
        Actions.clickButtonXP(self, driver, Locators.PICTURES_BUTTON_XP)
        Actions.clickButtonID(self, driver, Locators.OK_MOVE_BUTTON_ID)
        driver.lock()
        driver.unlock()
        Actions.clickButtonXP(self, driver, Locators.SUBMENU_BUTTON_XP)
        Actions.clickButtonXP(self, driver, Locators.SELECT_ALL_BUTTON_XP)

        count_on_pictures_page_after = Actions.count_of_all_selected(self, driver)

        assert count_on_pictures_page_before < count_on_pictures_page_after
Exemplo n.º 2
0
    def __init__(self, base):
        gtk.VBox.__init__(self)
        base.device_thread.join()

        drivers = Driver()
        if drivers.status:
            #Error
            warnwiew = WarnPage(drivers.output, base)
            self.pack_start(warnwiew)
        else:
            drivers.get_drivers()
            dri_list = drivers.dri_list

            #judgment ncard+icard (temporary)
            icard = ncard = False
            for key in base.pcid:
                if base.pcid[key] == "display":
                    id = key.split(":")[0]
                    if id == "8086":
                        icard = True
                    elif id == "10DE":
                        ncard = True

            #Tip bar
            tipbar = DriverBar(dri_list, base, icard, ncard)
            self.pack_start(tipbar, False)

            #content view
            contentview = DriverContent(dri_list, base, icard, ncard)
            self.pack_start(contentview)

        self.show_all()
Exemplo n.º 3
0
    def __init__(self, base):
        gtk.VBox.__init__(self)
        base.device_thread.join()
        
        drivers = Driver()
        if drivers.status:
            #Error
            warnwiew = WarnPage(drivers.output, base)
            self.pack_start(warnwiew)
        else:
            drivers.get_drivers()
            dri_list = drivers.dri_list

            #judgment ncard+icard (temporary)
            icard = ncard = False
            for key in base.pcid:
                if base.pcid[key] == "display":
                    id = key.split(":")[0]
                    if id == "8086":
                        icard = True
                    elif id == "10DE":
                        ncard = True

            #Tip bar
            tipbar = DriverBar(dri_list, base, icard, ncard)
            self.pack_start(tipbar, False)

            #content view
            contentview = DriverContent(dri_list, base, icard, ncard)
            self.pack_start(contentview)

        self.show_all()
Exemplo n.º 4
0
class TestDrivers(object):

    """
    Simple test to test the testing functionality (driver)
    """

    def setup_method(self, method):
        self.client = MockMonitor()
        self.driver = Driver(self.client)

    def teardown_method(self, method):
        self.client.stop()
        MockMonitor.static_stop()

    def assertEventCount(self, count):
        assert count == len(self.client.events)

    def testCallback(self):
        l = []
        self.driver.add(CallbackEvent(1, lambda: l.append(True)))
        self.driver.run()
        assert 1 == len(l)
        self.assertEventCount(0)  # Events don't get passed on callbacks

    def testInfo(self):
        self.driver.add(InfoEvent(1, monitors.EventInfo()))
        self.driver.run()
        self.assertEventCount(1)
Exemplo n.º 5
0
class TestDrivers(object):

    """
    Simple test to test the testing functionality (driver)
    """

    def setup_method(self, method):
        self.client = MockMonitor()
        self.driver = Driver(self.client)

    def teardown_method(self, method):
        self.client.stop()
        MockMonitor.static_stop()

    def assertEventCount(self, count):
        assert count == len(self.client.events)

    def testCallback(self):
        l = []
        self.driver.add(CallbackEvent(1, lambda: l.append(True)))
        self.driver.run()
        assert 1 == len(l)
        self.assertEventCount(0)  # Events don't get passed on callbacks

    def testInfo(self):
        self.driver.add(InfoEvent(1, monitors.EventInfo()))
        self.driver.run()
        self.assertEventCount(1)
    def test_2d_or_3d_is_on(self, driver):
        Actions.clickButtonXP(self, driver, Locators.MENU_BUTTON_XP)
        Actions.clickButtonXP(self, driver, Locators.SD_CARD_BUTTON_XP)
        Actions.clickButtonXP(self, driver, Locators.TEST_FOLDER_BUTTON_XP)
        Actions.clickButtonXP(self, driver, Locators.BUGS_FOLDER_BUTTON_XP)

        # Test *.mp4 is playing
        Actions.clickButtonXP(self, driver, Locators.V4_TEST_VIDEO)
        # time.sleep(1)
        assert Actions.is3DBacklightOn(self) is True
        # time.sleep(1)
        driver.tap([(150, 150)])
        Actions.clickButtonID(self, driver, Locators.INTERLACE_BUTTON_ID)
        # time.sleep(1)
        assert Actions.is3DBacklightOn(self) is False
Exemplo n.º 7
0
    def test_open_app_page(self, driver):
        Actions.clickButtonID(self, driver, MainLocators.SEARCH_BUTTON_ID)

        # Check "<-" button
        Actions.clickButtonID(self, driver, SearchLocators.BACK_BUTTON_ID)

        assert Actions.isObjectExistsID(self, driver,
                                        MainLocators.LOGO_ID) is True

        Actions.clickButtonID(self, driver, MainLocators.SEARCH_BUTTON_ID)

        # Check placeholder
        search_field_text = Actions.getTextID(self, driver,
                                              SearchLocators.SEARCH_FIELD_ID)

        assert search_field_text[0:6] == StaticData.SEARCH_FIELD_TEXT

        # Open app from autocomplete results
        Actions.search_field(self,
                             driver).set_value(StaticData.FIRST_PART_OF_WORD)
        time.sleep(2)

        assert Actions.isObjectExistsID(
            self, driver, AppPageLocators.GALLERY_BLOCK_ID) is False

        Actions.clickButtonID(self, driver, SearchLocators.RED_PLAYER_ICON_ID)

        assert Actions.isObjectExistsID(
            self, driver, AppPageLocators.GALLERY_BLOCK_ID) is True

        Actions.clickButtonID(self, driver, AppPageLocators.BACK_BUTTON_ID)

        assert Actions.isObjectExistsID(
            self, driver, AppPageLocators.GALLERY_BLOCK_ID) is False

        # Open app from general results
        driver.long_press_keycode(66)

        Actions.clickButtonID(self, driver,
                              SearchLocators.RESULTS_APP_COVER_IMAGE)

        assert Actions.isObjectExistsID(
            self, driver, AppPageLocators.GALLERY_BLOCK_ID) is True

        Actions.clickButtonID(self, driver, AppPageLocators.BACK_BUTTON_ID)

        assert Actions.isObjectExistsID(
            self, driver, AppPageLocators.GALLERY_BLOCK_ID) is False
Exemplo n.º 8
0
    def test_create_folder_select_one_all_about(self, driver):
        Actions.clickButtonXP(self, driver, Locators.MENU_BUTTON_XP)
        Actions.clickButtonXP(self, driver, Locators.PICTURES_BUTTON_XP)
        Actions.clickButtonXP(self, driver, Locators.SUBMENU_BUTTON_XP)

        # Test about page
        Actions.clickButtonXP(self, driver, Locators.ABOUT_BUTTON_XP)

        assert Actions.getTextID(self, driver, Locators.PAGE_TITLE_ID) == 'About'
        assert Actions.version_text(self, driver) == 'Version:'

        driver.press_keycode(4)

        # Test check select all
        Actions.clickButtonXP(self, driver, Locators.SUBMENU_BUTTON_XP)
        Actions.clickButtonXP(self, driver, Locators.SELECT_ALL_BUTTON_XP)

        assert Actions.count_of_selected_on_the_screen(self, driver) > 3

        Actions.clickButtonXP(self, driver, Locators.BACK_BUTTON_IF_SELECTED_XP)

        # Select one
        Actions.longtap(self, driver, Locators.ONE_IMAGE_TO_SELECT_XP)

        assert Actions.isObjectExistsID(self, driver, Locators.IS_SELECTED_FILE_ID) == True

        Actions.clickButtonXP(self, driver, Locators.BACK_BUTTON_IF_SELECTED_XP)

        # Test create new folder
        first_file = Actions.getTextXP(self, driver, Locators.FIRST_ITEM_TEXT_PICTURES_PAGE_XP)
        Actions.clickButtonXP(self, driver, Locators.SUBMENU_BUTTON_XP)
        Actions.clickButtonXP(self, driver, Locators.NEW_FOLDER_BUTTON_XP)

        assert Actions.getTextID(self, driver, Locators.POPUP_NAME_ID) == 'Create new folder'

        Actions.fill_field_id(self, driver)
        Actions.clickButtonID(self, driver, Locators.POPUP_SAVE_BUTTON_ID)

        assert Actions.getTextXP(self, driver, Locators.FIRST_ITEM_TEXT_PICTURES_PAGE_XP) != first_file
Exemplo n.º 9
0
    def __init__(self, base):
        gtk.VBox.__init__(self)
        base.device_thread.join()
        
        drivers = Driver()
        if drivers.status:
            #Error
            warnwiew = WarnPage(drivers.output, base)
            self.pack_start(warnwiew)
        else:
            drivers.get_drivers()
            dri_list = drivers.dri_list
            
            #Tip bar
            tipbar = DriverBar(dri_list, base)
            self.pack_start(tipbar, False)

            #content view
            contentview = DriverContent(dri_list, base)
            self.pack_start(contentview)

        self.show_all()
    def test_open_picture_portrait_landscape(self, driver):
        Actions.clickButtonXP(self, driver, Locators.MENU_BUTTON_XP)
        Actions.clickButtonXP(self, driver, Locators.SD_CARD_BUTTON_XP)
        Actions.clickButtonXP(self, driver, Locators.TEST_FOLDER_BUTTON_XP)
        Actions.clickButtonXP(self, driver, Locators.PICTURES_FOLDER_BUTTON_XP)

        # Test picture is displayed in PORTRAIT mode
        assert driver.orientation == 'PORTRAIT'

        # Test *.jpg is playing
        Actions.clickButtonXP(self, driver, Locators.JPEG_FILE_XP)
        time.sleep(1)
        driver.tap([(150, 150)])
        file_name = Actions.getTextID(self, driver, Locators.PICTURE_NAME_ID)
        assert file_name == 'jpg_test'

        driver.press_keycode(4)
        video_page_title = Actions.getTextID(self, driver, Locators.PAGE_TITLE_ID)
        assert video_page_title == 'Pictures'

        # Test picture is playing in LANDSCAPE mode
        driver.orientation = 'LANDSCAPE'
        assert driver.orientation == 'LANDSCAPE'

        # Test *.jpg is playing
        Actions.clickButtonXP(self, driver, Locators.JPEG_FILE_XP)
        time.sleep(1)
        driver.tap([(150, 150)])
        file_name = Actions.getTextID(self, driver, Locators.PICTURE_NAME_ID)
        assert file_name == 'jpg_test'

        driver.press_keycode(4)
        video_page_title = Actions.getTextID(self, driver, Locators.PAGE_TITLE_ID)
        assert video_page_title == 'Pictures'

        driver.orientation = 'PORTRAIT'
        assert driver.orientation == 'PORTRAIT'
Exemplo n.º 11
0
 def setup_method(self, method):
     self.uuid = str(uuid.uuid4())
     self.dir = create_path(folder=True) / self.uuid
     self.dir.makedirs()
     self.sim = Simulator(self.dir)
     self.driver = Driver(self.sim)
Exemplo n.º 12
0
 def setup_method(self, method):
     self.uuid = str(uuid.uuid4())
     self.dir = old_div(create_path(folder=True), self.uuid)
     self.dir.makedirs()
     self.sim = Simulator(self.dir)
     self.driver = Driver(self.sim)
Exemplo n.º 13
0
class TestSimulator(object):

    """
    Simple test to test the testing functionality (simulator)
    """

    def setup_method(self, method):
        self.uuid = str(uuid.uuid4())
        self.dir = old_div(create_path(folder=True), self.uuid)
        self.dir.makedirs()
        self.sim = Simulator(self.dir)
        self.driver = Driver(self.sim)

    def teardown_method(self, method):
        assert 0 == len(self.driver.errors)

    def assertErrors(self, count=1):
        assert count == len(self.driver.errors)
        for i in range(count):
            self.driver.errors.pop()

    def testRelativeTest(self):
        assert (old_div(self.dir, "foo")).parpath(self.dir)
        assert (self.dir / "foo" / "bar" / "baz").parpath(self.dir)
        # Not relative
        assert not (path("/")).parpath(self.dir)
        assert not (path("/root")).parpath(self.dir)
        assert not (path(".")).parpath(self.dir)

    def testBad(self):
        self.driver.add(InfoEvent(1, monitors.EventInfo(
            "foo", monitors.EventType.Create)))
        self.driver.run()
        self.assertErrors()

    def testSimpleCreate(self):
        self.driver.add(InfoEvent(1, monitors.EventInfo(
            old_div(self.dir, "foo"), monitors.EventType.Create)))
        self.driver.run()

    def testBadCreate(self):
        self.driver.add(InfoEvent(1, monitors.EventInfo(
            old_div(self.dir, "foo"), monitors.EventType.Create)))
        self.driver.add(InfoEvent(1, monitors.EventInfo(
            old_div(self.dir, "foo"), monitors.EventType.Create)))
        self.driver.run()
        self.assertErrors()

    def testBadModify(self):
        self.driver.add(InfoEvent(1, monitors.EventInfo(
            old_div(self.dir, "foo"), monitors.EventType.Modify)))
        self.driver.run()
        self.assertErrors()

    def testSimpleModify(self):
        self.driver.add(InfoEvent(1, monitors.EventInfo(
            old_div(self.dir, "foo"), monitors.EventType.Create)))
        self.driver.add(InfoEvent(1, monitors.EventInfo(
            old_div(self.dir, "foo"), monitors.EventType.Modify)))
        self.driver.run()

    def testBadDelete(self):
        self.driver.add(InfoEvent(1, monitors.EventInfo(
            old_div(self.dir, "foo"), monitors.EventType.Delete)))
        self.driver.run()
        self.assertErrors()

    def testSimpleDelete(self):
        self.driver.add(InfoEvent(1, monitors.EventInfo(
            old_div(self.dir, "foo"), monitors.EventType.Create)))
        self.driver.add(InfoEvent(1, monitors.EventInfo(
            old_div(self.dir, "foo"), monitors.EventType.Delete)))
        self.driver.run()

    def testSimpleDeleteWithModify(self):
        self.driver.add(InfoEvent(1, monitors.EventInfo(
            old_div(self.dir, "foo"), monitors.EventType.Create)))
        self.driver.add(InfoEvent(1, monitors.EventInfo(
            old_div(self.dir, "foo"), monitors.EventType.Modify)))
        self.driver.add(InfoEvent(1, monitors.EventInfo(
            old_div(self.dir, "foo"), monitors.EventType.Delete)))
        self.driver.run()

    def testDirectoryMethodsInfo(self):
        self.driver.add(InfoEvent(1, monitors.EventInfo(
            old_div(self.dir, "foo"), monitors.EventType.Create)))
        self.driver.add(InfoEvent(1, monitors.EventInfo(
            old_div(self.dir, "foo"), monitors.EventType.Modify)))
        self.driver.add(InfoEvent(1, monitors.EventInfo(
            old_div(self.dir, "foo"), monitors.EventType.Delete)))
        self.driver.run()

    def testDirectoryMethodsDirInfo(self):
        self.driver.add(DirInfoEvent(1, monitors.EventInfo(
            old_div(self.dir, "dir"), monitors.EventType.Create)))
        self.driver.add(DirInfoEvent(1, monitors.EventInfo(
            old_div(self.dir, "dir"), monitors.EventType.Modify)))
        self.driver.add(DirInfoEvent(1, monitors.EventInfo(
            old_div(self.dir, "dir"), monitors.EventType.Delete)))
        self.driver.run()

    def testDirectoryDoesntExistOnModify(self):
        self.driver.add(DirInfoEvent(1, monitors.EventInfo(
            old_div(self.dir, "dir"), monitors.EventType.Modify)))
        self.driver.run()
        self.assertErrors()

    def testDirectoryDoesntExistOnDelete(self):
        self.driver.add(DirInfoEvent(1, monitors.EventInfo(
            old_div(self.dir, "dir"), monitors.EventType.Delete)))
        self.driver.run()
        self.assertErrors()
Exemplo n.º 14
0
 def setup_method(self, method):
     self.client = MockMonitor()
     self.driver = Driver(self.client)
    def test_open_video_portrait_landscape(self, driver):
        Actions.clickButtonXP(self, driver, Locators.MENU_BUTTON_XP)
        Actions.clickButtonXP(self, driver, Locators.SD_CARD_BUTTON_XP)
        Actions.clickButtonXP(self, driver, Locators.TEST_FOLDER_BUTTON_XP)
        Actions.clickButtonXP(self, driver, Locators.VIDEOS_FOLDER_BUTTON_XP)

        # Test video is playing in PORTRAIT mode
        assert driver.orientation == 'PORTRAIT'

        # Test *.mp4 is playing
        Actions.clickButtonXP(self, driver, Locators.MP4_FILE_XP)
        time.sleep(1)
        driver.tap([(150, 150)])
        start_time = Actions.getTextID(self, driver, Locators.TIME_POSITION_ID)
        time.sleep(3)
        end_time1 = Actions.getTextID(self, driver, Locators.TIME_POSITION_ID)
        assert start_time != end_time1

        driver.orientation = 'LANDSCAPE'
        assert driver.orientation == 'LANDSCAPE'
        time.sleep(1)
        driver.tap([(150, 150)])
        start_time = Actions.getTextID(self, driver, Locators.TIME_POSITION_ID)
        time.sleep(3)
        end_time2 = Actions.getTextID(self, driver, Locators.TIME_POSITION_ID)
        assert start_time != end_time2
        assert end_time1 <= end_time2

        driver.press_keycode(4)
        video_page_title = Actions.getTextID(self, driver, Locators.PAGE_TITLE_ID)
        assert video_page_title == 'Video'

        # Test video is playing in LANDSCAPE mode
        driver.orientation = 'LANDSCAPE'
        assert driver.orientation == 'LANDSCAPE'

        # Test *.mp4 is playing
        Actions.clickButtonXP(self, driver, Locators.MP4_FILE_XP)
        time.sleep(1)
        driver.tap([(150, 150)])
        start_time = Actions.getTextID(self, driver, Locators.TIME_POSITION_ID)
        time.sleep(3)
        end_time3 = Actions.getTextID(self, driver, Locators.TIME_POSITION_ID)
        assert start_time != end_time3

        driver.orientation = 'PORTRAIT'
        assert driver.orientation == 'PORTRAIT'
        time.sleep(1)
        driver.tap([(150, 150)])
        start_time = Actions.getTextID(self, driver, Locators.TIME_POSITION_ID)
        time.sleep(3)
        end_time4 = Actions.getTextID(self, driver, Locators.TIME_POSITION_ID)
        assert start_time != end_time4
        assert end_time3 <= end_time4

        driver.press_keycode(4)
        video_page_title = Actions.getTextID(self, driver, Locators.PAGE_TITLE_ID)
        assert video_page_title == 'Video'

        # driver.orientation = 'PORTRAIT'
        assert driver.orientation == 'PORTRAIT'
Exemplo n.º 16
0
    def test_media_files_types(self, driver):

        #TODO to hadle permissions
        if Actions.isObjectExistsID(self, driver,
                                    Locators.ALLOW_ACCESS_BUTTON_ID) == True:
            Actions.clickButtonID(self, driver,
                                  Locators.ALLOW_ACCESS_BUTTON_ID)

        Actions.clickButtonXP(self, driver, Locators.MENU_BUTTON_XP)
        Actions.clickButtonXP(self, driver, Locators.SD_CARD_BUTTON_XP)
        Actions.clickButtonXP(self, driver, Locators.TEST_FOLDER_BUTTON_XP)
        Actions.clickButtonXP(self, driver, Locators.VIDEOS_FOLDER_BUTTON_XP)

        # Test *.mp4 is playing
        Actions.clickButtonXP(self, driver, Locators.MP4_FILE_XP)
        time.sleep(1)
        driver.tap([(150, 150)])
        start_time = Actions.getTextID(self, driver, Locators.TIME_POSITION_ID)
        time.sleep(3)
        end_time = Actions.getTextID(self, driver, Locators.TIME_POSITION_ID)
        assert start_time != end_time
        driver.press_keycode(4)

        # Test *.mkv is playing
        Actions.clickButtonXP(self, driver, Locators.MKV_FILE_XP)
        time.sleep(1)
        driver.tap([(150, 150)])
        start_time = Actions.getTextID(self, driver, Locators.TIME_POSITION_ID)
        time.sleep(3)
        end_time = Actions.getTextID(self, driver, Locators.TIME_POSITION_ID)
        assert start_time != end_time
        driver.press_keycode(4)

        # Test *.3gp is playing
        Actions.clickButtonXP(self, driver, Locators.GP3_FILE_XP)
        time.sleep(1)
        driver.tap([(150, 150)])
        start_time = Actions.getTextID(self, driver, Locators.TIME_POSITION_ID)
        time.sleep(3)
        end_time = Actions.getTextID(self, driver, Locators.TIME_POSITION_ID)
        assert start_time != end_time

        driver.press_keycode(4)
        time.sleep(1)
        driver.press_keycode(4)
        Actions.clickButtonXP(self, driver, Locators.PICTURES_FOLDER_BUTTON_XP)

        # Test *.jpg is playing
        Actions.clickButtonXP(self, driver, Locators.JPEG_FILE_XP)
        time.sleep(1)
        driver.tap([(150, 150)])
        file_name = Actions.getTextID(self, driver, Locators.PICTURE_NAME_ID)
        assert file_name == 'jpg_test'

        driver.press_keycode(4)

        # Test *.png is playing
        Actions.clickButtonXP(self, driver, Locators.PNG_FILE_XP)
        time.sleep(1)
        driver.tap([(150, 150)])
        file_name = Actions.getTextID(self, driver, Locators.PICTURE_NAME_ID)
        assert file_name == 'png_test'

        driver.press_keycode(4)

        # Test *.webp is playing
        Actions.clickButtonXP(self, driver, Locators.WEBP_FILE_XP)
        time.sleep(1)
        driver.tap([(150, 150)])
        file_name = Actions.getTextID(self, driver, Locators.PICTURE_NAME_ID)
        assert file_name == 'webp_test'
Exemplo n.º 17
0
save_state_path = "headless_levels/level-" + opts.level + ".state"

if not os.path.exists(save_state_path):
    raise Exception("Could not find save file: ", save_state_path)
print("The starting level is set to: ", save_state_path)

controller = Controller()
epoch_no = 0
num_stacked_frames = 3
num_skipped_frames = 4
rollout_size = 128
mini_batch_size = 1
epoch_per_rollout = 3
num_env = 8
memory = Memory(num_env, rollout_size, 512)
driver = Driver(num_env, opts.level, save_state_path, 10000, num_stacked_frames, num_skipped_frames, opts.use_cache, opts.record)
rp = RewardProcessor(num_env, rollout_size)
all_visited_levels = set()

frame_mean = driver.frame_mean
frame_std = driver.frame_std

model = Model(controller.all_moves().size, frame_mean, frame_std)

train_counter = 0

tf.config = tf.ConfigProto(allow_soft_placement=True, log_device_placement=True)
tf.config.operation_timeout_in_ms = 60000

with tf.Session(config=tf.config) as sess:
    #saver = tf.train.Saver(max_to_keep=25)
Exemplo n.º 18
0
    def test_search(self, driver):
        Actions.clickButtonID(self, driver, MainLocators.SEARCH_BUTTON_ID)

        # Check first part of word
        Actions.search_field(self,
                             driver).set_value(StaticData.FIRST_PART_OF_WORD)
        time.sleep(2)

        assert Actions.isObjectExistsID(
            self, driver, SearchLocators.RED_PLAYER_ICON_ID) is True

        first_autocomplete_result_name = Actions.getTextXP(
            self, driver, SearchLocators.RED_PLAYER_NAME_XP)
        assert first_autocomplete_result_name == StaticData.RED_PLAYER_NAME

        assert Actions.count_of_elements_id(
            self, driver, SearchLocators.RESULTS_APP_COVER_IMAGE) == 0

        driver.long_press_keycode(66)

        assert Actions.count_of_elements_id(
            self, driver, SearchLocators.RESULTS_APP_COVER_IMAGE) == 3

        Actions.clickButtonID(self, driver,
                              SearchLocators.CLEAR_FIELD_BUTTON_ID)

        assert Actions.isObjectExistsID(
            self, driver, SearchLocators.RED_PLAYER_ICON_ID) is False
        assert Actions.isObjectExistsXP(
            self, driver, SearchLocators.RED_PLAYER_NAME_XP) is False
        # TODO assert Actions.isObjectExistsID() check more than 1 result

        # Check middle part of word
        Actions.search_field(self,
                             driver).set_value(StaticData.MIDDLE_PART_OF_WORD)
        time.sleep(2)

        assert Actions.isObjectExistsID(
            self, driver, SearchLocators.RED_PLAYER_ICON_ID) is True

        first_autocomplete_result_name = Actions.getTextXP(
            self, driver, SearchLocators.RED_PLAYER_NAME_XP)
        assert first_autocomplete_result_name == StaticData.RED_PLAYER_NAME

        Actions.clickButtonID(self, driver,
                              SearchLocators.CLEAR_FIELD_BUTTON_ID)

        assert Actions.isObjectExistsID(
            self, driver, SearchLocators.RED_PLAYER_ICON_ID) is False
        assert Actions.isObjectExistsXP(
            self, driver, SearchLocators.RED_PLAYER_NAME_XP) is False
        # TODO check that 1 result

        # Check end part of word
        Actions.search_field(self,
                             driver).set_value(StaticData.END_PART_OF_WORD)
        time.sleep(2)

        assert Actions.isObjectExistsID(
            self, driver, SearchLocators.RED_PLAYER_ICON_ID) is True

        first_autocomplete_result_name = Actions.getTextXP(
            self, driver, SearchLocators.RED_PLAYER_NAME_XP)
        assert first_autocomplete_result_name == StaticData.RED_PLAYER_NAME

        Actions.clickButtonID(self, driver,
                              SearchLocators.CLEAR_FIELD_BUTTON_ID)

        assert Actions.isObjectExistsID(
            self, driver, SearchLocators.RED_PLAYER_ICON_ID) is False
        assert Actions.isObjectExistsXP(
            self, driver, SearchLocators.RED_PLAYER_NAME_XP) is False
        # TODO check that 1 result

        # Check two symbols - no results
        Actions.search_field(self, driver).set_value(StaticData.TWO_SYMBOLS)

        assert Actions.count_of_elements_id(self, driver,
                                            SearchLocators.APP_NAME_ID) == 0

        Actions.clickButtonID(self, driver,
                              SearchLocators.CLEAR_FIELD_BUTTON_ID)

        # Check more than 3 symbols
        Actions.search_field(self, driver).set_value(StaticData.SIX_SYMBOLS)

        assert Actions.isObjectExistsID(
            self, driver, SearchLocators.RED_PLAYER_ICON_ID) is True

        first_autocomplete_result_name = Actions.getTextXP(
            self, driver, SearchLocators.RED_PLAYER_NAME_XP)
        assert first_autocomplete_result_name == StaticData.RED_PLAYER_NAME
        assert Actions.count_of_elements_id(self, driver,
                                            SearchLocators.APP_NAME_ID) == 1

        Actions.clickButtonID(self, driver,
                              SearchLocators.CLEAR_FIELD_BUTTON_ID)

        # Check not existing app
        Actions.search_field(self,
                             driver).set_value(StaticData.NOT_EXISTING_APP)

        assert Actions.count_of_elements_id(self, driver,
                                            SearchLocators.APP_NAME_ID) == 0

        Actions.clickButtonID(self, driver,
                              SearchLocators.CLEAR_FIELD_BUTTON_ID)
Exemplo n.º 19
0
class TestSimulator(object):

    """
    Simple test to test the testing functionality (simulator)
    """

    def setup_method(self, method):
        self.uuid = str(uuid.uuid4())
        self.dir = create_path(folder=True) / self.uuid
        self.dir.makedirs()
        self.sim = Simulator(self.dir)
        self.driver = Driver(self.sim)

    def teardown_method(self, method):
        assert 0 == len(self.driver.errors)

    def assertErrors(self, count=1):
        assert count == len(self.driver.errors)
        for i in range(count):
            self.driver.errors.pop()

    def testRelativeTest(self):
        assert (self.dir / "foo").parpath(self.dir)
        assert (self.dir / "foo" / "bar" / "baz").parpath(self.dir)
        # Not relative
        assert not (path("/")).parpath(self.dir)
        assert not (path("/root")).parpath(self.dir)
        assert not (path(".")).parpath(self.dir)

    def testBad(self):
        self.driver.add(InfoEvent(1, monitors.EventInfo(
            "foo", monitors.EventType.Create)))
        self.driver.run()
        self.assertErrors()

    def testSimpleCreate(self):
        self.driver.add(InfoEvent(1, monitors.EventInfo(
            self.dir / "foo", monitors.EventType.Create)))
        self.driver.run()

    def testBadCreate(self):
        self.driver.add(InfoEvent(1, monitors.EventInfo(
            self.dir / "foo", monitors.EventType.Create)))
        self.driver.add(InfoEvent(1, monitors.EventInfo(
            self.dir / "foo", monitors.EventType.Create)))
        self.driver.run()
        self.assertErrors()

    def testBadModify(self):
        self.driver.add(InfoEvent(1, monitors.EventInfo(
            self.dir / "foo", monitors.EventType.Modify)))
        self.driver.run()
        self.assertErrors()

    def testSimpleModify(self):
        self.driver.add(InfoEvent(1, monitors.EventInfo(
            self.dir / "foo", monitors.EventType.Create)))
        self.driver.add(InfoEvent(1, monitors.EventInfo(
            self.dir / "foo", monitors.EventType.Modify)))
        self.driver.run()

    def testBadDelete(self):
        self.driver.add(InfoEvent(1, monitors.EventInfo(
            self.dir / "foo", monitors.EventType.Delete)))
        self.driver.run()
        self.assertErrors()

    def testSimpleDelete(self):
        self.driver.add(InfoEvent(1, monitors.EventInfo(
            self.dir / "foo", monitors.EventType.Create)))
        self.driver.add(InfoEvent(1, monitors.EventInfo(
            self.dir / "foo", monitors.EventType.Delete)))
        self.driver.run()

    def testSimpleDeleteWithModify(self):
        self.driver.add(InfoEvent(1, monitors.EventInfo(
            self.dir / "foo", monitors.EventType.Create)))
        self.driver.add(InfoEvent(1, monitors.EventInfo(
            self.dir / "foo", monitors.EventType.Modify)))
        self.driver.add(InfoEvent(1, monitors.EventInfo(
            self.dir / "foo", monitors.EventType.Delete)))
        self.driver.run()

    def testDirectoryMethodsInfo(self):
        self.driver.add(InfoEvent(1, monitors.EventInfo(
            self.dir / "foo", monitors.EventType.Create)))
        self.driver.add(InfoEvent(1, monitors.EventInfo(
            self.dir / "foo", monitors.EventType.Modify)))
        self.driver.add(InfoEvent(1, monitors.EventInfo(
            self.dir / "foo", monitors.EventType.Delete)))
        self.driver.run()

    def testDirectoryMethodsDirInfo(self):
        self.driver.add(DirInfoEvent(1, monitors.EventInfo(
            self.dir / "dir", monitors.EventType.Create)))
        self.driver.add(DirInfoEvent(1, monitors.EventInfo(
            self.dir / "dir", monitors.EventType.Modify)))
        self.driver.add(DirInfoEvent(1, monitors.EventInfo(
            self.dir / "dir", monitors.EventType.Delete)))
        self.driver.run()

    def testDirectoryDoesntExistOnModify(self):
        self.driver.add(DirInfoEvent(1, monitors.EventInfo(
            self.dir / "dir", monitors.EventType.Modify)))
        self.driver.run()
        self.assertErrors()

    def testDirectoryDoesntExistOnDelete(self):
        self.driver.add(DirInfoEvent(1, monitors.EventInfo(
            self.dir / "dir", monitors.EventType.Delete)))
        self.driver.run()
        self.assertErrors()
Exemplo n.º 20
0
 def setup_method(self, method):
     self.client = MockMonitor()
     self.driver = Driver(self.client)