예제 #1
0
	def __init__(self):
		SectionedConfigDict.__init__(self)
		self['Desktop Entry'].define(self._definitions)
		self.encoding = zim.fs.ENCODING
		if self.encoding == 'mbcs':
			self.encoding = 'utf-8'
예제 #2
0
    def testDialog(self):
        '''Test ExportDialog'''
        from zim.gui.exportdialog import ExportDialog, ExportDoneDialog

        dir = Dir(self.create_tmp_dir())

        notebook = tests.new_notebook(fakedir='/foo/bar')

        ui = tests.MockObject()
        ui.notebook = notebook
        ui.page = Path('foo')
        ui.uistate = SectionedConfigDict()

        ## Test export all pages
        dialog = ExportDialog(ui)
        dialog.set_page(0)

        page = dialog.get_page()
        page.form['selection'] = 'all'
        dialog.next_page()

        page = dialog.get_page()
        page.form['format'] = 'HTML'
        page.form['template'] = 'Print'
        dialog.next_page()

        page = dialog.get_page()
        page.form['folder'] = dir
        page.form['index'] = 'INDEX_PAGE'
        with tests.DialogContext(ExportDoneDialog):
            dialog.assert_response_ok()

        file = dir.file('Test/foo.html')
        self.assertTrue(file.exists())
        text = file.read()
        self.assertTrue('<!-- Wiki content -->' in text, 'template used')
        self.assertTrue('<h1>Foo</h1>' in text)

        #~ print dialog.uistate
        self.assertEqual(dialog.uistate, ui.uistate['ExportDialog'])
        self.assertIsInstance(dialog.uistate['output_folder'], Dir)

        ## Test export single page
        dialog = ExportDialog(ui)
        dialog.set_page(0)

        page = dialog.get_page()
        page.form['selection'] = 'page'
        page.form['page'] = 'Test:foo'
        dialog.next_page()

        page = dialog.get_page()
        page.form['format'] = 'HTML'
        page.form['template'] = 'Print'
        dialog.next_page()

        page = dialog.get_page()
        page.form['file'] = dir.file('SINGLE_FILE_EXPORT.html').path
        with tests.DialogContext(ExportDoneDialog):
            dialog.assert_response_ok()

        file = dir.file('SINGLE_FILE_EXPORT.html')
        self.assertTrue(file.exists())
        text = file.read()
        self.assertTrue('<!-- Wiki content -->' in text, 'template used')
        self.assertTrue('<h1>Foo</h1>' in text)

        #~ print dialog.uistate
        self.assertEqual(dialog.uistate, ui.uistate['ExportDialog'])
        self.assertIsInstance(dialog.uistate['output_file'], File)
        self.assertIsInstance(dialog.uistate['output_folder'],
                              Dir)  # Keep this in state as well
예제 #3
0
 def __init__(self):
     SectionedConfigDict.__init__(self)
     self['Desktop Entry'].define(self._definitions)
예제 #4
0
	def __init__(self):
		SectionedConfigDict.__init__(self)
		self['Desktop Entry'].define(self._definitions)
		self.encoding = zim.fs.ENCODING
		if self.encoding == 'mbcs':
			self.encoding = 'utf-8'
예제 #5
0
	def testDialog(self):
		'''Test ExportDialog'''
		from zim.gui.exportdialog import ExportDialog, ExportDoneDialog

		dir = Dir(self.create_tmp_dir())
		notebook = self.setUpNotebook(content={'foo': 'test 123\n', 'bar': 'test 123\n'})

		window = Gtk.Window()
		window.config = tests.MockObject()
		window.config.uistate = SectionedConfigDict()

		## Test export all pages
		dialog = ExportDialog(window, notebook, Path('foo'))
		dialog.set_page(0)

		page = dialog.get_page()
		page.form['selection'] = 'all'
		dialog.next_page()

		page = dialog.get_page()
		page.form['format'] = 'HTML'
		page.form['template'] = 'Print'
		dialog.next_page()

		page = dialog.get_page()
		page.form['folder'] = dir
		page.form['index'] = 'INDEX_PAGE'
		with tests.DialogContext(ExportDoneDialog):
			dialog.assert_response_ok()

		file = dir.file('foo.html')
		self.assertTrue(file.exists())
		text = file.read()
		self.assertTrue('<!-- Wiki content -->' in text, 'template used')

		#~ print dialog.uistate
		self.assertEqual(dialog.uistate, window.config.uistate['ExportDialog'])
		self.assertIsInstance(dialog.uistate['output_folder'], Dir)

		## Test export single page
		dialog = ExportDialog(window, notebook, Path('foo'))
		dialog.set_page(0)

		page = dialog.get_page()
		page.form['selection'] = 'page'
		page.form['page'] = 'foo'
		dialog.next_page()

		page = dialog.get_page()
		page.form['format'] = 'HTML'
		page.form['template'] = 'Print'
		dialog.next_page()

		page = dialog.get_page()
		page.form['file'] = dir.file('SINGLE_FILE_EXPORT.html').path
		with tests.DialogContext(ExportDoneDialog):
			dialog.assert_response_ok()

		file = dir.file('SINGLE_FILE_EXPORT.html')
		self.assertTrue(file.exists())
		text = file.read()
		self.assertTrue('<!-- Wiki content -->' in text, 'template used')

		#~ print dialog.uistate
		self.assertEqual(dialog.uistate, window.config.uistate['ExportDialog'])
		self.assertIsInstance(dialog.uistate['output_file'], OldFile)
		self.assertIsInstance(dialog.uistate['output_folder'], OldDir) # Keep this in state as well
예제 #6
0
    def runTest(self):
        plugin = InsertSymbolPlugin(ConfigManager())

        pageview = setUpPageView()
        textview = pageview.view
        buffer = textview.get_buffer()
        pageview.undostack = UndoStackManager(buffer)

        mainwindow = tests.MockObject()
        mainwindow.pageview = pageview
        mainwindow.ui = tests.MockObject()  # XXX
        mainwindow.ui.uimanager = tests.MockObject()  # XXX
        mainwindow.ui.uistate = SectionedConfigDict()

        plugin.extend(mainwindow, 'MainWindow')

        print '\n!! Two GtkWarnings expected here for gdk display !!'
        # Need a window to get the widget realized
        window = gtk.Window()
        window.add(pageview)
        pageview.realize()
        textview.realize()

        # insert on end-of-word with space
        press(textview, r'\alpha ')
        text = buffer.get_text(*buffer.get_bounds())
        self.assertEqual(text, ALPHA + ' ')

        # Check undo - first undo replace, then the insert space
        pageview.undo()
        text = buffer.get_text(*buffer.get_bounds())
        self.assertEqual(text, r'\alpha ')
        pageview.undo()
        text = buffer.get_text(*buffer.get_bounds())
        self.assertEqual(text, r'\alpha')  # no trailing space

        # insert on end-of-word with ;
        buffer.clear()
        press(textview, r'\alpha;')
        text = buffer.get_text(*buffer.get_bounds())
        self.assertEqual(text, ALPHA)  # no trailing space

        # no insert in code or pre section
        buffer.clear()
        pageview.toggle_format(VERBATIM)
        press(textview, r'\alpha ')
        text = buffer.get_text(*buffer.get_bounds())
        self.assertEqual(text, r'\alpha ')  # no replace

        # test dialog
        def check_dialog(dialog):
            self.assertIsInstance(dialog, InsertSymbolDialog)
            dialog.iconview.item_activated(
                (9, ))  # path for 10th item in symbol list
            dialog.iconview.item_activated(
                (10, ))  # path for 11th item in symbol list
            dialog.iconview.item_activated(
                (11, ))  # path for 12th item in symbol list
            dialog.assert_response_ok()

        buffer.clear()
        mainwindow_ext = plugin.get_extension(MainWindowExtension)
        with tests.DialogContext(check_dialog):
            mainwindow_ext.insert_symbol()
        text = buffer.get_text(*buffer.get_bounds())
        self.assertEqual(text, EACUTE + ECIRC + EGRAVE)