Пример #1
0
    def test_builtin_name(self):
        eq = self.assertEqual
        d = self.page
        item_list = ['edit Classic', 'edit Dark', 'edit New']

        # Not in old_themes, defaults name to first item.
        editConf.SetOption('main', 'Theme', 'name', 'spam')
        d.builtinlist.SetMenu(item_list, 'edit Dark')
        eq(mainpage, {'Theme': {'name': 'edit Classic', 'name2': 'edit Dark'}})
        eq(d.theme_message['text'], 'New theme, see Help')
        eq(d.paint_theme_sample.called, 1)

        # Not in old themes - uses name2.
        changes.clear()
        editConf.SetOption('main', 'Theme', 'name', 'edit New')
        d.builtinlist.SetMenu(item_list, 'edit Dark')
        eq(mainpage, {'Theme': {'name2': 'edit Dark'}})
        eq(d.theme_message['text'], 'New theme, see Help')
        eq(d.paint_theme_sample.called, 2)

        # Builtin name in old_themes.
        changes.clear()
        d.builtinlist.SetMenu(item_list, 'edit Classic')
        eq(mainpage, {'Theme': {'name': 'edit Classic', 'name2': ''}})
        eq(d.theme_message['text'], '')
        eq(d.paint_theme_sample.called, 3)
Пример #2
0
    def test_create_new_key_set_and_save_new_key_set(self):
        eq = self.assertEqual
        d = self.page

        # Use default as previously active keyset.
        d.keyset_source.set(True)
        d.builtin_name.set('edit Classic Windows')
        first_new = 'my new custom key set'
        second_new = 'my second custom keyset'

        # No changes, so keysets are an exact copy.
        self.assertNotIn(first_new, editConf.userCfg)
        d.create_new_key_set(first_new)
        eq(editConf.GetSectionList('user', 'keys'), [first_new])
        eq(editConf.GetKeySet('edit Classic Windows'),
           editConf.GetKeySet(first_new))
        eq(d.custom_name.get(), first_new)
        self.assertFalse(d.keyset_source.get())  # Use custom set.
        eq(d.set_keys_type.called, 1)

        # Test that changed keybindings are in new keyset.
        changes.add_option('keys', first_new, 'copy', '<Key-F11>')
        self.assertNotIn(second_new, editConf.userCfg)
        d.create_new_key_set(second_new)
        eq(editConf.GetSectionList('user', 'keys'), [first_new, second_new])
        self.assertNotEqual(editConf.GetKeySet(first_new),
                            editConf.GetKeySet(second_new))
        # Check that difference in keysets was in option `copy` from `changes`.
        editConf.SetOption('keys', first_new, 'copy', '<Key-F11>')
        eq(editConf.GetKeySet(first_new), editConf.GetKeySet(second_new))
Пример #3
0
    def test_create_new_and_save_new(self):
        eq = self.assertEqual
        d = self.page

        # Use default as previously active theme.
        d.theme_source.set(True)
        d.builtin_name.set('edit Classic')
        first_new = 'my new custom theme'
        second_new = 'my second custom theme'

        # No changes, so themes are an exact copy.
        self.assertNotIn(first_new, editConf.userCfg)
        d.create_new(first_new)
        eq(editConf.GetSectionList('user', 'highlight'), [first_new])
        eq(editConf.GetThemeDict('default', 'edit Classic'),
           editConf.GetThemeDict('user', first_new))
        eq(d.custom_name.get(), first_new)
        self.assertFalse(d.theme_source.get())  # Use custom set.
        eq(d.set_theme_type.called, 1)

        # Test that changed targets are in new theme.
        changes.add_option('highlight', first_new, 'hit-background', 'yellow')
        self.assertNotIn(second_new, editConf.userCfg)
        d.create_new(second_new)
        eq(editConf.GetSectionList('user', 'highlight'),
           [first_new, second_new])
        self.assertNotEqual(editConf.GetThemeDict('user', first_new),
                            editConf.GetThemeDict('user', second_new))
        # Check that difference in themes was in `hit-background` from `changes`.
        editConf.SetOption('highlight', first_new, 'hit-background', 'yellow')
        eq(editConf.GetThemeDict('user', first_new),
           editConf.GetThemeDict('user', second_new))
Пример #4
0
    def test_load_key_cfg(self):
        tracers.detach()
        d = self.page
        eq = self.assertEqual

        # Use builtin keyset with no user keysets created.
        editConf.CurrentKeys = mock.Mock(return_value='edit Classic OSX')
        d.load_key_cfg()
        self.assertTrue(d.keyset_source.get())
        # builtinlist sets variable builtin_name to the CurrentKeys default.
        eq(d.builtin_name.get(), 'edit Classic OSX')
        eq(d.custom_name.get(), '- no custom keys -')
        eq(d.custom_keyset_on.state(), ('disabled', ))
        eq(d.set_keys_type.called, 1)
        eq(d.load_keys_list.called, 1)
        eq(d.load_keys_list.args, ('edit Classic OSX', ))

        # Builtin keyset with non-empty user keyset list.
        editConf.SetOption('keys', 'test1', 'option', 'value')
        editConf.SetOption('keys', 'test2', 'option2', 'value2')
        d.load_key_cfg()
        eq(d.builtin_name.get(), 'edit Classic OSX')
        eq(d.custom_name.get(), 'test1')
        eq(d.set_keys_type.called, 2)
        eq(d.load_keys_list.called, 2)
        eq(d.load_keys_list.args, ('edit Classic OSX', ))

        # Use custom keyset.
        editConf.CurrentKeys = mock.Mock(return_value='test2')
        editConf.default_keys = mock.Mock(return_value='edit Modern Unix')
        editConf.SetOption('main', 'Keys', 'default', '0')
        d.load_key_cfg()
        self.assertFalse(d.keyset_source.get())
        eq(d.builtin_name.get(), 'edit Modern Unix')
        eq(d.custom_name.get(), 'test2')
        eq(d.set_keys_type.called, 3)
        eq(d.load_keys_list.called, 3)
        eq(d.load_keys_list.args, ('test2', ))

        del editConf.CurrentKeys, editConf.default_keys
        tracers.attach()
Пример #5
0
    def test_load_theme_cfg(self):
        tracers.detach()
        d = self.page
        eq = self.assertEqual

        # Use builtin theme with no user themes created.
        editConf.CurrentTheme = mock.Mock(return_value='edit Classic')
        d.load_theme_cfg()
        self.assertTrue(d.theme_source.get())
        # builtinlist sets variable builtin_name to the CurrentTheme default.
        eq(d.builtin_name.get(), 'edit Classic')
        eq(d.custom_name.get(), '- no custom themes -')
        eq(d.custom_theme_on.state(), ('disabled', ))
        eq(d.set_theme_type.called, 1)
        eq(d.paint_theme_sample.called, 1)
        eq(d.set_highlight_target.called, 1)

        # Builtin theme with non-empty user theme list.
        editConf.SetOption('highlight', 'test1', 'option', 'value')
        editConf.SetOption('highlight', 'test2', 'option2', 'value2')
        d.load_theme_cfg()
        eq(d.builtin_name.get(), 'edit Classic')
        eq(d.custom_name.get(), 'test1')
        eq(d.set_theme_type.called, 2)
        eq(d.paint_theme_sample.called, 2)
        eq(d.set_highlight_target.called, 2)

        # Use custom theme.
        editConf.CurrentTheme = mock.Mock(return_value='test2')
        editConf.SetOption('main', 'Theme', 'default', '0')
        d.load_theme_cfg()
        self.assertFalse(d.theme_source.get())
        eq(d.builtin_name.get(), 'edit Classic')
        eq(d.custom_name.get(), 'test2')
        eq(d.set_theme_type.called, 3)
        eq(d.paint_theme_sample.called, 3)
        eq(d.set_highlight_target.called, 3)

        del editConf.CurrentTheme
        tracers.attach()
Пример #6
0
 def test_load_general_cfg(self):
     # Set to wrong values, load, check right values.
     eq = self.assertEqual
     d = self.page
     d.startup_edit.set(1)
     d.autosave.set(1)
     d.win_width.set(1)
     d.win_height.set(1)
     d.helplist.insert('end', 'bad')
     d.user_helplist = ['bad', 'worse']
     editConf.SetOption('main', 'HelpFiles', '1', 'name;file')
     d.load_general_cfg()
     eq(d.startup_edit.get(), 0)
     eq(d.autosave.get(), 0)
     eq(d.win_width.get(), '80')
     eq(d.win_height.get(), '40')
     eq(d.helplist.get(0, 'end'), ('name', ))
     eq(d.user_helplist, [('name', 'file', '1')])
Пример #7
0
    def test_keybinding(self):
        editConf.SetOption('extensions', 'ZzDummy', 'enable', 'True')
        d = self.page
        d.custom_name.set('my custom keys')
        d.bindingslist.delete(0, 'end')
        d.bindingslist.insert(0, 'copy')
        d.bindingslist.insert(1, 'z-in')
        d.bindingslist.selection_set(0)
        d.bindingslist.selection_anchor(0)
        # Core binding - adds to keys.
        d.keybinding.set('<Key-F11>')
        self.assertEqual(keyspage, {'my custom keys': {'copy': '<Key-F11>'}})

        # Not a core binding - adds to extensions.
        d.bindingslist.selection_set(1)
        d.bindingslist.selection_anchor(1)
        d.keybinding.set('<Key-F11>')
        self.assertEqual(extpage,
                         {'ZzDummy_cfgBindings': {
                             'z-in': '<Key-F11>'
                         }})
Пример #8
0
    def test_builtin_name(self):
        eq = self.assertEqual
        d = self.page
        editConf.userCfg['main'].remove_section('Keys')
        item_list = [
            'edit Classic Windows', 'edit Classic OSX', 'edit Modern UNIX'
        ]

        # Not in old_keys, defaults name to first item.
        d.builtinlist.SetMenu(item_list, 'edit Modern UNIX')
        eq(mainpage, {
            'Keys': {
                'name': 'edit Classic Windows',
                'name2': 'edit Modern UNIX'
            }
        })
        eq(d.keys_message['text'], 'New key set, see Help')
        eq(d.load_keys_list.called, 1)
        eq(d.load_keys_list.args, ('edit Modern UNIX', ))

        # Not in old keys - uses name2.
        changes.clear()
        editConf.SetOption('main', 'Keys', 'name', 'edit Classic Unix')
        d.builtinlist.SetMenu(item_list, 'edit Modern UNIX')
        eq(mainpage, {'Keys': {'name2': 'edit Modern UNIX'}})
        eq(d.keys_message['text'], 'New key set, see Help')
        eq(d.load_keys_list.called, 2)
        eq(d.load_keys_list.args, ('edit Modern UNIX', ))

        # Builtin name in old_keys.
        changes.clear()
        d.builtinlist.SetMenu(item_list, 'edit Classic OSX')
        eq(mainpage, {'Keys': {'name': 'edit Classic OSX', 'name2': ''}})
        eq(d.keys_message['text'], '')
        eq(d.load_keys_list.called, 3)
        eq(d.load_keys_list.args, ('edit Classic OSX', ))