コード例 #1
0
    def testSelectedAttach_html (self):
        Attachment (self._testpage).attach (self.files)
        parent = LinkDialog (self.wnd)
        Tester.dialogTester.appendOk()
        selectedString = u'{}/add.png'.format (PAGE_ATTACH_DIR)

        controller = HtmlLinkDialogController (self._testpage,
                                               parent,
                                               selectedString)
        controller.showDialog()

        self.assertIn (u'{}/accept.png'.format (PAGE_ATTACH_DIR),
                       parent.linkText.GetItems())
        self.assertIn (u'{}/add.png'.format (PAGE_ATTACH_DIR),
                       parent.linkText.GetItems())
        self.assertIn (u'{}/html.txt'.format (PAGE_ATTACH_DIR),
                       parent.linkText.GetItems())

        self.assertEqual (controller.link,
                          u'{}/add.png'.format (PAGE_ATTACH_DIR))
        self.assertEqual (controller.comment,
                          u'{}/add.png'.format (PAGE_ATTACH_DIR))
        self.assertEqual (controller.linkResult,
                          u'<a href="{attach}/add.png">{attach}/add.png</a>'.format (attach=PAGE_ATTACH_DIR))

        self.assertEqual (parent.linkText.GetValue(), u'{}/add.png'.format (PAGE_ATTACH_DIR))
コード例 #2
0
ファイル: link.py プロジェクト: DavidWHouse/outwiker
def insertLink(application):
    codeEditor = application.mainWindow.pagePanel.pageView.codeEditor

    with LinkDialog(application.mainWindow) as dlg:
        linkController = WikiLinkDialogController(application,
                                                  application.selectedPage,
                                                  dlg,
                                                  codeEditor.GetSelectedText())

        if linkController.showDialog() == wx.ID_OK:
            codeEditor.replaceText(linkController.linkResult)
コード例 #3
0
    def testSelectedText_html (self):
        parent = LinkDialog (self.wnd)
        Tester.dialogTester.appendOk()
        selectedString = u'бла-бла-бла'

        controller = HtmlLinkDialogController (self._testpage,
                                               parent,
                                               selectedString)
        controller.showDialog()

        self.assertEqual (controller.link, u'')
        self.assertEqual (controller.comment, selectedString)
        self.assertEqual (controller.linkResult, u'<a href="">бла-бла-бла</a>')
コード例 #4
0
    def testSelectedHttpLink2_html (self):
        parent = LinkDialog (self.wnd)
        Tester.dialogTester.appendOk()
        selectedString = u'HTTP://jenyay.net'

        controller = HtmlLinkDialogController (self._testpage,
                                               parent,
                                               selectedString)
        controller.showDialog()

        self.assertEqual (controller.link, selectedString)
        self.assertEqual (controller.comment, selectedString)
        self.assertEqual (controller.linkResult, u'<a href="HTTP://jenyay.net">HTTP://jenyay.net</a>')
コード例 #5
0
    def testSelectedPageLink_html (self):
        parent = LinkDialog (self.wnd)
        Tester.dialogTester.appendOk()
        selectedString = u'page://__adsfadfasdf'

        controller = HtmlLinkDialogController (self._testpage,
                                               parent,
                                               selectedString)
        controller.showDialog()

        self.assertEqual (controller.link, selectedString)
        self.assertEqual (controller.comment, selectedString)
        self.assertEqual (controller.linkResult, u'<a href="page://__adsfadfasdf">page://__adsfadfasdf</a>')
コード例 #6
0
    def testSelectedHttpLink_wiki (self):
        parent = LinkDialog (self.wnd)
        Tester.dialogTester.appendOk()
        selectedString = u'http://jenyay.net'

        controller = WikiLinkDialogController (Application,
                                               self._testpage,
                                               parent,
                                               selectedString)
        controller.showDialog()

        self.assertEqual (controller.link, selectedString)
        self.assertEqual (controller.comment, selectedString)
        self.assertEqual (controller.linkResult, u'[[http://jenyay.net]]')
コード例 #7
0
    def testEmpty_wiki (self):
        parent = LinkDialog (self.wnd)
        Tester.dialogTester.appendOk()
        selectedString = u''

        controller = WikiLinkDialogController (Application,
                                               self._testpage,
                                               parent,
                                               selectedString)
        controller.showDialog()

        self.assertEqual (controller.link, u'')
        self.assertEqual (controller.comment, u'')
        self.assertEqual (controller.linkResult, u'[[]]')
コード例 #8
0
    def testSelectedPageLink_wiki (self):
        parent = LinkDialog (self.wnd)
        Tester.dialogTester.appendOk()
        selectedString = u'page://__adsfadfasdf'

        controller = WikiLinkDialogController (Application,
                                               self._testpage,
                                               parent,
                                               selectedString)
        controller.showDialog()

        self.assertEqual (controller.link, selectedString)
        self.assertEqual (controller.comment, selectedString)
        self.assertEqual (controller.linkResult, u'[[page://__adsfadfasdf]]')
コード例 #9
0
    def testAttach_wiki (self):
        Attachment (self._testpage).attach (self.files)
        parent = LinkDialog (self.wnd)
        Tester.dialogTester.appendOk()
        selectedString = u''

        controller = WikiLinkDialogController (Application,
                                               self._testpage,
                                               parent,
                                               selectedString)
        controller.showDialog()

        self.assertIn (u'Attach:accept.png', parent.linkText.GetItems())
        self.assertIn (u'Attach:add.png', parent.linkText.GetItems())
        self.assertIn (u'Attach:html.txt', parent.linkText.GetItems())
コード例 #10
0
    def testClipboardPageLink_wiki (self):
        parent = LinkDialog (self.wnd)
        Tester.dialogTester.appendOk()
        selectedString = u''
        clipboardText = u'page://_asdfasdfasdf'
        copyTextToClipboard (clipboardText)

        controller = WikiLinkDialogController (Application,
                                               self._testpage,
                                               parent,
                                               selectedString)
        controller.showDialog()

        self.assertEqual (controller.link, clipboardText)
        self.assertEqual (controller.comment, clipboardText)
        self.assertEqual (controller.linkResult, u'[[page://_asdfasdfasdf]]')
コード例 #11
0
    def testClipboardHttpLink2_wiki (self):
        parent = LinkDialog (self.wnd)
        Tester.dialogTester.appendOk()
        selectedString = u''
        clipboardText = u'HTTP://jenyay.net'
        copyTextToClipboard (clipboardText)

        controller = WikiLinkDialogController (Application,
                                               self._testpage,
                                               parent,
                                               selectedString)
        controller.showDialog()

        self.assertEqual (controller.link, clipboardText)
        self.assertEqual (controller.comment, clipboardText)
        self.assertEqual (controller.linkResult, u'[[HTTP://jenyay.net]]')
コード例 #12
0
    def testAttach_html (self):
        Attachment (self._testpage).attach (self.files)
        parent = LinkDialog (self.wnd)
        Tester.dialogTester.appendOk()
        selectedString = u''

        controller = HtmlLinkDialogController (self._testpage,
                                               parent,
                                               selectedString)
        controller.showDialog()

        self.assertIn (u'{}/accept.png'.format (PAGE_ATTACH_DIR),
                       parent.linkText.GetItems())
        self.assertIn (u'{}/add.png'.format (PAGE_ATTACH_DIR),
                       parent.linkText.GetItems())
        self.assertIn (u'{}/html.txt'.format (PAGE_ATTACH_DIR),
                       parent.linkText.GetItems())
コード例 #13
0
    def testClipboardPageLink_html (self):
        parent = LinkDialog (self.wnd)
        Tester.dialogTester.appendOk()
        selectedString = u''
        clipboardText = u'page://_asdfasdfasdf'
        copyTextToClipboard (clipboardText)

        controller = HtmlLinkDialogController (self._testpage,
                                               parent,
                                               selectedString)
        controller.showDialog()

        self.assertEqual (controller.link, clipboardText)
        self.assertEqual (controller.comment, clipboardText)
        self.assertEqual (
            controller.linkResult,
            u'<a href="page://_asdfasdfasdf">page://_asdfasdfasdf</a>')
コード例 #14
0
    def testClipboardFtpLink_html (self):
        parent = LinkDialog (self.wnd)
        Tester.dialogTester.appendOk()
        selectedString = u''
        clipboardText = u'ftp://jenyay.net'
        copyTextToClipboard (clipboardText)

        controller = HtmlLinkDialogController (self._testpage,
                                               parent,
                                               selectedString)
        controller.showDialog()

        self.assertEqual (controller.link, clipboardText)
        self.assertEqual (controller.comment, clipboardText)
        self.assertEqual (
            controller.linkResult,
            u'<a href="ftp://jenyay.net">ftp://jenyay.net</a>')
コード例 #15
0
    def testLinkStyle_02 (self):
        self._config.linkStyleOptions.value = 1

        dlg = LinkDialog (self.wnd)
        Tester.dialogTester.appendOk()
        selectedString = u''

        controller = WikiLinkDialogController (Application,
                                               self._testpage,
                                               dlg,
                                               selectedString)

        dlg.link = u'Ссылка'
        dlg.comment = u'Коммент'

        controller.showDialog()

        self.assertEqual (controller.linkResult, u'[[Ссылка | Коммент]]')
コード例 #16
0
    def testSelectedAttach_wiki (self):
        Attachment (self._testpage).attach (self.files)
        parent = LinkDialog (self.wnd)
        Tester.dialogTester.appendOk()
        selectedString = u'Attach:add.png'

        controller = WikiLinkDialogController (Application,
                                               self._testpage,
                                               parent,
                                               selectedString)
        controller.showDialog()

        self.assertIn (u'Attach:accept.png', parent.linkText.GetItems())
        self.assertIn (u'Attach:add.png', parent.linkText.GetItems())
        self.assertIn (u'Attach:html.txt', parent.linkText.GetItems())

        self.assertEqual (controller.link, u'Attach:add.png')
        self.assertEqual (controller.comment, u'Attach:add.png')
        self.assertEqual (controller.linkResult, u'[[Attach:add.png]]')

        self.assertEqual (parent.linkText.GetValue(), u'Attach:add.png')