コード例 #1
0
			def ok_store(dialog):
				# Click OK in the "Store Anyway" question dialog
				dialog.do_response(gtk.RESPONSE_YES)

			with tests.DialogContext(ok_store):
				dialog = self.dialogklass(MockUI(attachment_dir), '<title>', generator)
				dialog.set_text(self.invalidinput)
				dialog.assert_response_ok()

		# Check menu
		#~ plugin = self.pluginklass(MockUI())
		#~ menu = gtk.Menu()
		#~ plugin.do_populate_popup(menu, buffer, iter, image)


@tests.skipUnless(InsertEquationPlugin.check_dependencies_ok(), 'Missing dependencies')
class TestEquationEditor(TestGenerator):

	pluginklass = InsertEquationPlugin
	generatorklass = EquationGenerator

	validinput = r'''
c = \sqrt{ a^2 + b^2 }

\int_{-\infty}^{\infty} \frac{1}{x} \, dx

f(x) = \sum_{n = 0}^{\infty} \alpha_n x^n

x_{1,2}=\frac{-b\pm\sqrt{\color{Red}b^2-4ac}}{2a}

\hat a  \bar b  \vec c  x'  \dot{x}  \ddot{x}
コード例 #2
0
    def testDumpWiki(self):
        attachment_dir = self.setUpFolder(mock=tests.MOCK_ALWAYS_REAL)
        tests.ZIM_DATA_FOLDER.file('zim.png').copyto(
            attachment_dir.file('test.png'))

        notebook = self.setUpNotebook()
        notebook.get_attachments_dir = lambda *a: attachment_dir

        pageview = setUpPageView(notebook, text='{{./test.png?type=equation}}')
        pageview.textview.get_buffer().set_modified(True)
        tree = pageview.page.get_parsetree()
        text = WikiDumper().dump(tree)
        self.assertEqual(text, ['{{./test.png?type=equation}}\n'])


@tests.skipUnless(InsertEquationPlugin.check_dependencies_ok(),
                  'Missing dependencies')
class TestBackwardImageGeneratorWithPlugin(TestBackwardImageGeneratorNoPlugins
                                           ):
    def setUp(self):
        PluginManager.load_plugin('equationeditor')

    def testInsertObjectDialog(self):
        attachment_dir = self.setUpFolder(mock=tests.MOCK_ALWAYS_REAL)

        notebook = self.setUpNotebook()
        notebook.get_attachments_dir = lambda *a: attachment_dir
        page = notebook.get_page(Path('Test'))
        otype = PluginManager.insertedobjects['image+equation']

        def edit_dialog(dialog):
コード例 #3
0
	def testDumpWiki(self):
		attachment_dir = self.setUpFolder(mock=tests.MOCK_ALWAYS_REAL)
		LocalFolder(tests.ZIM_DATADIR).file('zim.png').copyto(attachment_dir.file('test.png'))

		notebook = self.setUpNotebook()
		notebook.get_attachments_dir = lambda *a: attachment_dir

		pageview = setUpPageView(notebook, text='{{./test.png?type=equation}}')
		pageview.textview.get_buffer().set_modified(True)
		tree = pageview.get_parsetree()
		text = WikiDumper().dump(tree)
		self.assertEquals(text, ['{{./test.png?type=equation}}\n'])


@tests.skipUnless(InsertEquationPlugin.check_dependencies_ok(), 'Missing dependencies')
class TestBackwardImageGeneratorWithPlugin(TestBackwardImageGeneratorNoPlugins):

	def setUp(self):
		PluginManager.load_plugin('equationeditor')

	def testInsertObjectDialog(self):
		attachment_dir = self.setUpFolder(mock=tests.MOCK_ALWAYS_REAL)

		notebook = self.setUpNotebook()
		notebook.get_attachments_dir = lambda *a: attachment_dir
		page = notebook.get_page(Path('Test'))
		otype = PluginManager.insertedobjects['image+equation']

		def edit_dialog(dialog):
			self.assertIsInstance(dialog, ImageGeneratorDialog)