示例#1
0
    def test_empty_01(self):
        '''
        Wiki is not added to Application
        '''
        watcher = AttachWatcher(self._application, self._period_ms)
        watcher.initialize()

        wx.MilliSleep(500)
        self.myYield()
        watcher.clear()
        self.assertEqual(self._eventCount, 0)
示例#2
0
    def test_empty_10_create_empty_attach_dir(self):
        self._application.wikiroot = self.wikiroot
        self._application.selectedPage = self.page_01

        watcher = AttachWatcher(self._application, self._period_ms)
        watcher.initialize()

        Attachment(self._application.selectedPage).getAttachPath(True)

        wx.MilliSleep(500)
        self.myYield()
        watcher.clear()
        self.assertEqual(self._eventCount, 0)
示例#3
0
    def test_add_files_01(self):
        self._application.wikiroot = self.wikiroot
        self._application.selectedPage = self.page_01

        watcher = AttachWatcher(self._application, self._period_ms)
        watcher.initialize()

        self._attach_files(self.page_01, ['add.png'])

        wx.MilliSleep(500)
        self.myYield()
        watcher.clear()
        self.assertEqual(self._eventCount, 1)
示例#4
0
    def test_rename_page_01(self):
        self._application.wikiroot = self.wikiroot
        self._application.selectedPage = self.page_01

        watcher = AttachWatcher(self._application, self._period_ms)
        watcher.initialize()

        self.page_01.title = 'Новый заголовок'

        wx.MilliSleep(500)
        self.myYield()
        watcher.clear()
        self.assertEqual(self._eventCount, 0)
示例#5
0
    def test_empty_03(self):
        '''
        Wiki added to Application _after_ AttachWatcher initializing.
        No selected pages.
        '''
        watcher = AttachWatcher(self._application, self._period_ms)
        watcher.initialize()
        self._application.wikiroot = self.wikiroot

        wx.MilliSleep(500)
        self.myYield()
        watcher.clear()
        self.assertEqual(self._eventCount, 0)
示例#6
0
    def test_race_01(self):
        self._application.wikiroot = self.wikiroot
        self._application.selectedPage = self.page_01
        self._attach_files(self.page_01, ['add.png'])

        watcher = AttachWatcher(self._application, 500)
        watcher.initialize()

        self._application.selectedPage = self.page_02
        wx.MilliSleep(1000)
        self.myYield()
        watcher.clear()
        self.assertEqual(self._eventCount, 0)
示例#7
0
    def test_empty_04(self):
        '''
        Wiki added to Application _before_ AttachWatcher initializing.
        Selected page.
        '''
        self._application.wikiroot = self.wikiroot
        self._application.selectedPage = self.page_01

        watcher = AttachWatcher(self._application, self._period_ms)
        watcher.initialize()

        wx.MilliSleep(500)
        self.myYield()
        watcher.clear()
        self.assertEqual(self._eventCount, 0)
示例#8
0
    def test_remove_empty_attach_dir(self):
        self._application.wikiroot = self.wikiroot
        self._application.selectedPage = self.page_01

        attach = Attachment(self.page_01)
        attach_dir = attach.getAttachPath(True)

        watcher = AttachWatcher(self._application, self._period_ms)
        watcher.initialize()

        shutil.rmtree(attach_dir)

        wx.MilliSleep(500)
        self.myYield()
        watcher.clear()
        self.assertEqual(self._eventCount, 0)
示例#9
0
    def test_empty_08(self):
        '''
        Change the selected page
        '''
        self._application.wikiroot = self.wikiroot
        self._application.selectedPage = self.page_01

        watcher = AttachWatcher(self._application, self._period_ms)
        watcher.initialize()

        self._application.selectedPage = self.page_02

        wx.MilliSleep(500)
        self.myYield()
        watcher.clear()
        self.assertEqual(self._eventCount, 0)
示例#10
0
    def test_attach_touch_write(self):
        self._application.wikiroot = self.wikiroot
        self._application.selectedPage = self.page_01
        self._attach_files(self.page_01, ['add.png'])

        watcher = AttachWatcher(self._application, self._period_ms)
        watcher.initialize()

        attach = Attachment(self.page_01)
        with open(attach.getFullPath('add.png'), 'w'):
            pass

        wx.MilliSleep(500)
        self.myYield()
        watcher.clear()
        self.assertEqual(self._eventCount, 0)
示例#11
0
    def test_empty_09_close_wiki(self):
        '''
        Close current notes tree
        '''
        self._application.wikiroot = self.wikiroot
        self._application.selectedPage = self.page_01

        watcher = AttachWatcher(self._application, self._period_ms)
        watcher.initialize()

        self._application.wikiroot = None

        wx.MilliSleep(500)
        self.myYield()
        watcher.clear()
        self.assertEqual(self._eventCount, 0)
示例#12
0
    def test_attach_rename(self):
        self._application.wikiroot = self.wikiroot
        self._application.selectedPage = self.page_01
        self._attach_files(self.page_01, ['add.png'])

        attach = Attachment(self.page_01)
        src_fname = attach.getFullPath('add.png')
        dest_fname = attach.getFullPath('newname.png')

        watcher = AttachWatcher(self._application, self._period_ms)
        watcher.initialize()

        os.rename(src_fname, dest_fname)

        wx.MilliSleep(500)
        self.myYield()
        watcher.clear()
        self.assertEqual(self._eventCount, 1)
示例#13
0
    def test_switch_and_add_file(self):
        self._application.wikiroot = self.wikiroot
        self._application.selectedPage = self.page_01

        self._attach_files(self.page_01, ['add.png'])
        self._attach_files(self.page_02, ['add.png', 'dir.png'])

        watcher = AttachWatcher(self._application, self._period_ms)
        watcher.initialize()

        # Switch pages
        self._application.selectedPage = self.page_02
        self._attach_files(self.page_02, ['accept.png'])

        wx.MilliSleep(500)
        self.myYield()
        watcher.clear()
        self.assertEqual(self._eventCount, 1)
示例#14
0
    def test_empty_01(self):
        '''
        Wiki is not added to Application
        '''
        watcher = AttachWatcher(self._application, self._period_ms)
        watcher.initialize()

        wx.MilliSleep(500)
        self.myYield()
        watcher.clear()
        self.assertEqual(self._eventCount, 0)
示例#15
0
    def test_add_files_01(self):
        self._application.wikiroot = self.wikiroot
        self._application.selectedPage = self.page_01

        watcher = AttachWatcher(self._application, self._period_ms)
        watcher.initialize()

        self._attach_files(self.page_01, ['add.png'])

        wx.MilliSleep(500)
        self.myYield()
        watcher.clear()
        self.assertEqual(self._eventCount, 1)
示例#16
0
    def test_rename_page_01(self):
        self._application.wikiroot = self.wikiroot
        self._application.selectedPage = self.page_01

        watcher = AttachWatcher(self._application, self._period_ms)
        watcher.initialize()

        self.page_01.title = 'Новый заголовок'

        wx.MilliSleep(500)
        self.myYield()
        watcher.clear()
        self.assertEqual(self._eventCount, 0)
示例#17
0
    def test_empty_10_create_empty_attach_dir(self):
        self._application.wikiroot = self.wikiroot
        self._application.selectedPage = self.page_01

        watcher = AttachWatcher(self._application, self._period_ms)
        watcher.initialize()

        Attachment(self._application.selectedPage).getAttachPath(True)

        wx.MilliSleep(500)
        self.myYield()
        watcher.clear()
        self.assertEqual(self._eventCount, 0)
示例#18
0
    def test_empty_03(self):
        '''
        Wiki added to Application _after_ AttachWatcher initializing.
        No selected pages.
        '''
        watcher = AttachWatcher(self._application, self._period_ms)
        watcher.initialize()
        self._application.wikiroot = self.wikiroot

        wx.MilliSleep(500)
        self.myYield()
        watcher.clear()
        self.assertEqual(self._eventCount, 0)
示例#19
0
    def test_race_01(self):
        self._application.wikiroot = self.wikiroot
        self._application.selectedPage = self.page_01
        self._attach_files(self.page_01, ['add.png'])

        watcher = AttachWatcher(self._application, 500)
        watcher.initialize()

        self._application.selectedPage = self.page_02
        wx.MilliSleep(1000)
        self.myYield()
        watcher.clear()
        self.assertEqual(self._eventCount, 0)
示例#20
0
    def test_empty_04(self):
        '''
        Wiki added to Application _before_ AttachWatcher initializing.
        Selected page.
        '''
        self._application.wikiroot = self.wikiroot
        self._application.selectedPage = self.page_01

        watcher = AttachWatcher(self._application, self._period_ms)
        watcher.initialize()

        wx.MilliSleep(500)
        self.myYield()
        watcher.clear()
        self.assertEqual(self._eventCount, 0)
示例#21
0
    def test_empty_09_close_wiki(self):
        '''
        Close current notes tree
        '''
        self._application.wikiroot = self.wikiroot
        self._application.selectedPage = self.page_01

        watcher = AttachWatcher(self._application, self._period_ms)
        watcher.initialize()

        self._application.wikiroot = None

        wx.MilliSleep(500)
        self.myYield()
        watcher.clear()
        self.assertEqual(self._eventCount, 0)
示例#22
0
    def test_remove_empty_attach_dir(self):
        self._application.wikiroot = self.wikiroot
        self._application.selectedPage = self.page_01

        attach = Attachment(self.page_01)
        attach_dir = attach.getAttachPath(True)

        watcher = AttachWatcher(self._application, self._period_ms)
        watcher.initialize()

        shutil.rmtree(attach_dir)

        wx.MilliSleep(500)
        self.myYield()
        watcher.clear()
        self.assertEqual(self._eventCount, 0)
示例#23
0
    def test_empty_08(self):
        '''
        Change the selected page
        '''
        self._application.wikiroot = self.wikiroot
        self._application.selectedPage = self.page_01

        watcher = AttachWatcher(self._application, self._period_ms)
        watcher.initialize()

        self._application.selectedPage = self.page_02

        wx.MilliSleep(500)
        self.myYield()
        watcher.clear()
        self.assertEqual(self._eventCount, 0)
示例#24
0
    def test_attach_touch_write(self):
        self._application.wikiroot = self.wikiroot
        self._application.selectedPage = self.page_01
        self._attach_files(self.page_01, ['add.png'])

        watcher = AttachWatcher(self._application, self._period_ms)
        watcher.initialize()

        attach = Attachment(self.page_01)
        with open(attach.getFullPath('add.png'), 'w'):
            pass

        wx.MilliSleep(500)
        self.myYield()
        watcher.clear()
        self.assertEqual(self._eventCount, 0)
示例#25
0
    def test_switch_and_add_file(self):
        self._application.wikiroot = self.wikiroot
        self._application.selectedPage = self.page_01

        self._attach_files(self.page_01, ['add.png'])
        self._attach_files(self.page_02, ['add.png', 'dir.png'])

        watcher = AttachWatcher(self._application, self._period_ms)
        watcher.initialize()

        # Switch pages
        self._application.selectedPage = self.page_02
        self._attach_files(self.page_02, ['accept.png'])

        wx.MilliSleep(500)
        self.myYield()
        watcher.clear()
        self.assertEqual(self._eventCount, 1)
示例#26
0
    def test_attach_rename(self):
        self._application.wikiroot = self.wikiroot
        self._application.selectedPage = self.page_01
        self._attach_files(self.page_01, ['add.png'])

        attach = Attachment(self.page_01)
        src_fname = attach.getFullPath('add.png')
        dest_fname = attach.getFullPath('newname.png')

        watcher = AttachWatcher(self._application, self._period_ms)
        watcher.initialize()

        os.rename(src_fname, dest_fname)

        wx.MilliSleep(500)
        self.myYield()
        watcher.clear()
        self.assertEqual(self._eventCount, 1)
示例#27
0
    def __init__(self, application):
        super().__init__(None)
        self._application = application

        # Variables to accurate watch for main window state
        self._realSize = None
        self._realPosition = None
        self._realMaximized = False

        logger.debug(u'MainWindow initializing begin')

        self.mainWindowConfig = MainWindowConfig(self._application.config)

        # Флаг, обозначающий, что в цикле обработки стандартных сообщений
        # (например, копирования в буфер обмена) сообщение вернулось обратно
        self.__stdEventLoop = False

        logger.debug(u'MainWindow. Setup icon')
        self._setIcon()
        self.SetTitle(u"OutWiker")
        self._createMenu()
        self._createStatusBar()

        logger.debug(u'MainWindow. Create the MainWndController')
        self.controller = MainWndController(self, self._application)
        self.controller.loadMainWindowParams()

        if self.mainWindowConfig.maximized.value:
            self.Maximize()

        self._mainSizer = wx.FlexGridSizer(cols=1)
        self._mainSizer.AddGrowableCol(0)
        self._mainSizer.AddGrowableRow(1)
        self._toolbarContainer = ToolBar2Container(self)
        self._mainContentPanel = wx.Panel(self)

        self._mainSizer.Add(self._toolbarContainer, flag=wx.EXPAND)
        self._mainSizer.Add(self._mainContentPanel, flag=wx.EXPAND)
        self.SetSizer(self._mainSizer)

        logger.debug(u'MainWindow. Create the AuiManager')
        self.auiManager = wx.aui.AuiManager(self._mainContentPanel)
        self._createAuiPanes()
        self._createToolbars()

        logger.debug(u'MainWindow. Create the MainPanesController')
        self.__panesController = MainPanesController(self._application, self)

        self._bindGuiEvents()

        logger.debug(u'MainWindow. Create the TabsController')
        self.tabsController = TabsController(self.pagePanel.panel.tabsCtrl,
                                             self._application)

        self.attachWatcher = AttachWatcher(self._application,
                                           guidefines.ATTACH_CHECK_PERIOD)

        self._coreControllers = [
            WikiPageController(self._application),
            HtmlPageController(self._application),
            TextPageController(self._application),
            SearchPageController(self._application),
            PrefController(self._application),
            self.attachWatcher,
        ]

        logger.debug(u'MainWindow. Initialize the core controllers')
        self._initCoreControllers()

        logger.debug(u'MainWindow. Create the tray icon')
        self.taskBarIconController = getTrayIconController(
            self._application, self)

        logger.debug(u'MainWindow initializing end')
示例#28
0
    def createGui(self):
        """
        Создать пункты меню, кнопки на панелях инструментов и т.п.
        """
        logger.debug(u'MainWindow createGui started')
        logger.debug(u'MainWindow. Setup icon')
        self._setIcon()
        self.SetTitle(u"OutWiker")
        self._createMenu()
        self._createStatusBar()

        if self.mainWindowConfig.maximized.value:
            self.Maximize()

        self._mainSizer = wx.FlexGridSizer(cols=1)
        self._mainSizer.AddGrowableCol(0)
        self._mainSizer.AddGrowableRow(1)
        self._toolbarContainer = ToolBar2Container(self)
        self._mainContentPanel = wx.Panel(self)

        self._mainSizer.Add(self._toolbarContainer, flag=wx.EXPAND)
        self._mainSizer.Add(self._mainContentPanel, flag=wx.EXPAND)
        self.SetSizer(self._mainSizer)

        logger.debug(u'MainWindow. Create the AuiManager')

        self.auiManager = wx.aui.AuiManager(self._mainContentPanel,
                                            flags=wx.aui.AUI_MGR_DEFAULT
                                            | wx.aui.AUI_MGR_LIVE_RESIZE
                                            | wx.aui.AUI_MGR_ALLOW_FLOATING)

        self._createAuiPanes()
        self._createToolbars()

        logger.debug(u'MainWindow. Create the MainWndController')
        self.controller = MainWndController(self, self._application)
        self.controller.loadMainWindowParams()

        logger.debug(u'MainWindow. Create the MainPanesController')
        self.__panesController = MainPanesController(self._application, self)

        self._bindGuiEvents()

        logger.debug(u'MainWindow. Create the TabsController')
        self.tabsController = TabsController(self.pagePanel.panel.tabsCtrl,
                                             self._application)

        self.attachWatcher = AttachWatcher(self._application,
                                           guidefines.ATTACH_CHECK_PERIOD)

        self._coreControllers = [
            WikiPageController(self._application),
            HtmlPageController(self._application),
            TextPageController(self._application),
            SearchPageController(self._application),
            PrefController(self._application),
            self.attachWatcher,
        ]

        logger.debug(u'MainWindow. Initialize the core controllers')
        self._initCoreControllers()

        logger.debug(u'MainWindow. Create the tray icon')
        self.taskBarIconController = getTrayIconController(
            self._application, self)

        self.__panesController.loadPanesSize()
        self._addActionsGui()
        self.controller.enableGui()
        self.controller.updateRecentMenu()
        self.__panesController.updateViewMenu()
        self.treePanel.panel.addButtons()
        self.toaster = ToasterController(self, self._application)

        if self.mainWindowConfig.fullscreen.value:
            self._application.actionController.check(FullScreenAction.stringId,
                                                     True)
        logger.debug(u'MainWindow createGui ended')