]> granicus.if.org Git - python/commitdiff
Issue #21477: Add htests for Search and Replace dialogs.
authorTerry Jan Reedy <tjreedy@udel.edu>
Tue, 27 May 2014 07:30:44 +0000 (03:30 -0400)
committerTerry Jan Reedy <tjreedy@udel.edu>
Tue, 27 May 2014 07:30:44 +0000 (03:30 -0400)
Patch by Saimadhav Heblikar.

Lib/idlelib/ReplaceDialog.py
Lib/idlelib/SearchDialog.py
Lib/idlelib/TreeWidget.py
Lib/idlelib/idle_test/htest.py

index 54c270df23c5fbeac5a15d60957aa9887164f042..21cc92782bf404eae970f363c375f3e76199cf67 100644 (file)
@@ -187,3 +187,34 @@ class ReplaceDialog(SearchDialogBase):
     def close(self, event=None):
         SearchDialogBase.close(self, event)
         self.text.tag_remove("hit", "1.0", "end")
+
+def _replace_dialog(parent):
+    root = Tk()
+    root.title("Test ReplaceDialog")
+    width, height, x, y = list(map(int, re.split('[x+]', parent.geometry())))
+    root.geometry("+%d+%d"%(x, y + 150))
+
+    # mock undo delegator methods
+    def undo_block_start():
+        pass
+
+    def undo_block_stop():
+        pass
+
+    text = Text(root)
+    text.undo_block_start = undo_block_start
+    text.undo_block_stop = undo_block_stop
+    text.pack()
+    text.insert("insert","This is a sample string.\n"*10)
+
+    def show_replace():
+        text.tag_add(SEL, "1.0", END)
+        replace(text)
+        text.tag_remove(SEL, "1.0", END)
+
+    button = Button(root, text="Replace", command=show_replace)
+    button.pack()
+
+if __name__ == '__main__':
+    from idlelib.idle_test.htest import run
+    run(_replace_dialog)
index 3ba0cdb95d144a24215b5b679303a8a65143d1ed..2aadb8431fd1f76fa7c656d98483be31d03c120d 100644 (file)
@@ -65,3 +65,25 @@ class SearchDialog(SearchDialogBase):
         if pat:
             self.engine.setcookedpat(pat)
         return self.find_again(text)
+
+def _search_dialog(parent):
+    root = Tk()
+    root.title("Test SearchDialog")
+    width, height, x, y = list(map(int, re.split('[x+]', parent.geometry())))
+    root.geometry("+%d+%d"%(x, y + 150))
+    text = Text(root)
+    text.pack()
+    text.insert("insert","This is a sample string.\n"*10)
+
+    def show_find():
+        text.tag_add(SEL, "1.0", END)
+        s = _setup(text)
+        s.open(text)
+        text.tag_remove(SEL, "1.0", END)
+
+    button = Button(root, text="Search", command=show_find)
+    button.pack()
+
+if __name__ == '__main__':
+    from idlelib.idle_test.htest import run
+    run(_search_dialog)
index 38a96a70db5c6267d357b8e968b6d4e420fb0b6d..ebb1f02a15b113a58406264532a3e5b31a6b344e 100644 (file)
@@ -454,20 +454,11 @@ def _tree_widget(parent):
     root.title("Test TreeWidget")
     width, height, x, y = list(map(int, re.split('[x+]', parent.geometry())))
     root.geometry("+%d+%d"%(x, y + 150))
-    # test with scrollable canvas
     sc = ScrolledCanvas(root, bg="white", highlightthickness=0, takefocus=1)
     sc.frame.pack(expand=1, fill="both", side=LEFT)
     item = FileTreeItem(os.getcwd())
     node = TreeNode(sc.canvas, None, item)
     node.expand()
-
-    # test without scrollable canvas
-    canvas = Canvas(root, bg="white", highlightthickness=0)
-    canvas.pack(expand=0, fill="both", side=RIGHT)
-    item = FileTreeItem(os.getcwd())
-    node = TreeNode(canvas, None, item)
-    node.update()
-
     root.mainloop()
 
 if __name__ == '__main__':
index df92883f439075308ff1a60d5b221578a396eebd..8f78bf2ea1aa058163e2967745afae1950050635 100644 (file)
@@ -181,6 +181,22 @@ _percolator_spec = {
            "Test for actions like text entry, and removal."
     }
 
+_replace_dialog_spec = {
+    'file': 'ReplaceDialog',
+    'kwds': {},
+    'msg': "Click the 'Replace' button.\n"
+           "Test various replace options in the 'Replace dialog'.\n"
+           "Click [Close] or [X] to close to the 'Replace Dialog'."
+    }
+
+_search_dialog_spec = {
+    'file': 'SearchDialog',
+    'kwds': {},
+    'msg': "Click the 'Search' button.\n"
+           "Test various search options in the 'Search dialog'.\n"
+           "Click [Close] or [X] to close to the 'Search Dialog'."
+    }
+
 _scrolled_list_spec = {
     'file': 'ScrolledList',
     'kwds': {},
@@ -227,9 +243,7 @@ _tooltip_spec = {
 _tree_widget_spec = {
     'file': 'TreeWidget',
     'kwds': {},
-    'msg': "You should see two canvases side-by-side.\n"
-           "The left canvas is scrollable.\n"
-           "The right canvas is not scrollable.\n"
+    'msg': "The canvas is scrollable.\n"
            "Click on folders upto to the lowest level."
     }