示例#1
0
    def test_ho_graphical_icon_disappears(self):
        o = get_mock_graphical_output()
        overlay = HelpOverlay(lambda: True)
        mu = Menu([], get_mock_input(), o, name=ui_name, config={})
        mu.idle_loop = lambda *a, **k: True
        Canvas.fonts_dir = fonts_dir
        overlay.apply_to(mu)
        def activate():
            mu.before_activate()
            mu.to_foreground()
            mu.idle_loop()
            img_1 = o.display_image.call_args[0]
            mu.idle_loop()
            mu.refresh()
            img_2 = o.display_image.call_args[0]
            assert(img_1 == img_2)
            for i in range(overlay.duration):
                mu.idle_loop()
            mu.refresh()
            img_2 = o.display_image.call_args[0]
            assert(img_1 != img_2)
            mu.deactivate()  # KEY_LEFT

        with patch.object(mu, 'activate', side_effect=activate) as p:
            mu.activate()
示例#2
0
 def test_ho_keymap(self):
     overlay = HelpOverlay(lambda: True)
     mu = Menu([], get_mock_input(), get_mock_output(), name=ui_name, config={})
     overlay.apply_to(mu)
     self.assertIsNotNone(mu.keymap)
     assert("KEY_F5" in mu.keymap)
     assert(all([callable(v) for v in mu.keymap.values()]))
示例#3
0
 def test_ho_push_pop_callback(self):
     cb1 = lambda:True
     cb2 = lambda:False
     overlay = HelpOverlay(cb1)
     assert(overlay.get_key_and_callback()[1] == cb1)
     overlay.push_callback(cb2)
     assert(overlay.get_key_and_callback()[1] == cb2)
     overlay.pop_callback()
     assert(overlay.get_key_and_callback()[1] == cb1)
示例#4
0
    def test_ho_text_redraw(self):
        overlay = HelpOverlay(lambda: True)
        mu = Menu([["Hello"]], get_mock_input(), get_mock_output(), name=ui_name, config={})
        overlay.apply_to(mu)
        def scenario():
            mu.deactivate()
            assert not mu.in_foreground

        with patch.object(mu, 'idle_loop', side_effect=scenario) as p:
            mu.activate()
        assert mu.o.display_data.called
        assert mu.o.display_data.call_count == 1 #One in to_foreground
        assert mu.o.display_data.call_args[0] == ('Hello', mu.exit_entry[0])
示例#5
0
    def test_ho_graphical_redraw(self):
        o = get_mock_graphical_output()
        overlay = HelpOverlay(lambda: True)
        mu = Menu([], get_mock_input(), o, name=ui_name, config={})
        Canvas.fonts_dir = fonts_dir
        overlay.apply_to(mu)
        # Exiting immediately, but we should get at least one redraw
        def scenario():
            mu.deactivate()  # KEY_LEFT
            assert not mu.in_foreground

        with patch.object(mu, 'idle_loop', side_effect=scenario) as p:
            mu.activate()
        assert o.display_image.called
        assert o.display_image.call_count == 1 #One in to_foreground
示例#6
0
文件: main.py 项目: hpagseddy/ZPUI
def callback():
    listbox_contents = [
    ["NumberAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", 101],
    ["String", "stringstring"],
    ["Tuple", (1, 2, 3)]]
    lb = Listbox(listbox_contents, i, o)
    HelpOverlay(lambda: print("Halp plz")).apply_to(lb)
    lb.activate()
示例#7
0
def callback():
    c = [["Update ZPUI", git_updater.update, git_updater.settings],
         ["Bugreport", bugreport_ui.main_menu],
         ["Logging settings", logging_ui.config_logging],
         ["About", about.about]]
    menu = Menu(c, i, o, "ZPUI settings menu")
    help_text = "Press RIGHT on \"Update ZPUI\" to change OTA update settings (branch or git URL to use)"
    HelpOverlay(help_text).apply_to(menu)
    menu.activate()
示例#8
0
文件: main.py 项目: hpagseddy/ZPUI
 def learn_about_help_icon(self):
     o = HelpOverlay("test")
     c = Canvas(self.o)
     c.text("See this icon?->", (1, 1))
     c.text("When it appears,", (3, 10))
     c.text("press F5 to get help", (3, 19))
     c.text("Try now, or", (3, 28))
     c.text("press ENTER to skip", (3, 37))
     if not is_emulator():
         c.text("F5:", (5, 51))
         c.paste(local_path("f5_button_location.png"), (30, 50),
                 invert=True)
     o.draw_icon(c)
     Refresher(c.get_image,
               self.i,
               self.o,
               keymap={
                   "KEY_ENTER": "deactivate",
                   "KEY_F5": self.on_help_button_press
               }).activate()
     return True
示例#9
0
def callback():
    #Check if we have all the software necessary for the app to work
    #If not, show error messages and exit
    if nmap is None:
        PrettyPrinter("nmap Python module not found!", i, o, 3)
        return False
    try:
        nm = nmap.PortScanner()
    except nmap.nmap.PortScannerError:
        PrettyPrinter("nmap not installed!", i, o, 3)
        return False
    #Dump function support
    i.set_maskable_callback("KEY_F6", dump_current_scan_to_file)
    #Constructing and loading app main menu
    menu_contents = [["Smart scan", smart_scan],
                     ["Scan a network", scan_network_menu],
                     ["Scan arbitrary IP", scan_arbitrary_ip],
                     ["Scan localhost", scan_localhost]]
    menu = Menu(menu_contents, i, o)
    help_text = "Press F6 in the scan results menu to save the scan results into a file"
    HelpOverlay(help_text).apply_to(menu)
    menu.activate()
    #Have to remove the dump function callback because once application exits it isn't removed automatically
    i.remove_maskable_callback("KEY_F6")
示例#10
0
文件: main.py 项目: hpagseddy/ZPUI
 def on_start(self):
     PrettyPrinter("No image saving implemented yet!", self.i, self.o, 3)
     board = DrawingBoard(self.i, self.o)
     FunctionOverlay(["back", board.pick_tools], labels=["Exit", "Tools"]).apply_to(board)
     HelpOverlay(help_text).apply_to(board)
     board.activate()
示例#11
0
 def overlay_main_menu(self, menu):
     main_menu_help = "ZPUI main menu. Navigate the folders to get to different apps, or press KEY_PROG2 (anywhere in ZPUI) to get to the context menu."
     GridMenuNavOverlay().apply_to(menu)
     GridMenuSidebarOverlay(self.sidebar_cb).apply_to(menu)
     GridMenuLabelOverlay().apply_to(menu)
     HelpOverlay(main_menu_help).apply_to(menu)
示例#12
0
 def test_ho_apply(self):
     overlay = HelpOverlay(lambda: True)
     mu = Menu([], get_mock_input(), get_mock_output(), name=ui_name, config={})
     overlay.apply_to(mu)
     self.assertIsNotNone(overlay)
     self.assertIsNotNone(mu)
示例#13
0
 def test_ho_constructor(self):
     """tests constructor"""
     overlay = HelpOverlay(lambda: True)
     self.assertIsNotNone(overlay)