mirror of https://github.com/KLayout/klayout.git
Fixing tests for non-Qt builds
This commit is contained in:
parent
cd34125b0c
commit
7997d1375c
|
|
@ -37,141 +37,152 @@ class PluginFactory < RBA::PluginFactory
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class Plugin2EditorOptionsPage < RBA::EditorOptionsPage
|
has_qt = RBA.constants.member?(:EditorOptionsPage) && RBA.constants.member?(:MainWindow)
|
||||||
def initialize
|
if has_qt
|
||||||
super("title", 1)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
class Plugin2ConfigPage < RBA::ConfigPage
|
class Plugin2EditorOptionsPage < RBA::EditorOptionsPage
|
||||||
def initialize
|
def initialize
|
||||||
super("title")
|
super("title", 1)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
class Plugin2 < RBA::Plugin
|
class Plugin2ConfigPage < RBA::ConfigPage
|
||||||
def set_tp(tp)
|
def initialize
|
||||||
@tp = tp
|
super("title")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
def has_tracking_position
|
|
||||||
!!@tp
|
|
||||||
end
|
|
||||||
def tracking_position
|
|
||||||
@tp || RBA::DPoint::new
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
class PluginFactory2 < RBA::PluginFactory
|
class Plugin2 < RBA::Plugin
|
||||||
def initialize()
|
def set_tp(tp)
|
||||||
@ep = 0
|
@tp = tp
|
||||||
@cp = 0
|
end
|
||||||
@pi = nil
|
def has_tracking_position
|
||||||
register(1001, "plugin_for_test2", "Plugin2")
|
!!@tp
|
||||||
|
end
|
||||||
|
def tracking_position
|
||||||
|
@tp || RBA::DPoint::new
|
||||||
|
end
|
||||||
end
|
end
|
||||||
def create_plugin(manager, unused, view)
|
|
||||||
@pi = Plugin2::new
|
|
||||||
@pi
|
|
||||||
end
|
|
||||||
def create_editor_options_pages
|
|
||||||
add_editor_options_page(Plugin2EditorOptionsPage::new)
|
|
||||||
@ep += 1
|
|
||||||
end
|
|
||||||
def create_config_pages
|
|
||||||
add_config_page(Plugin2ConfigPage::new)
|
|
||||||
@cp += 1
|
|
||||||
end
|
|
||||||
def pi
|
|
||||||
@pi
|
|
||||||
end
|
|
||||||
def ep
|
|
||||||
@ep
|
|
||||||
end
|
|
||||||
def cp
|
|
||||||
@cp
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
class LayPlugin_TestClass < TestBase
|
class PluginFactory2 < RBA::PluginFactory
|
||||||
|
def initialize()
|
||||||
|
@ep = 0
|
||||||
|
@cp = 0
|
||||||
|
@pi = nil
|
||||||
|
register(1001, "plugin_for_test2", "Plugin2")
|
||||||
|
end
|
||||||
|
def create_plugin(manager, unused, view)
|
||||||
|
@pi = Plugin2::new
|
||||||
|
@pi
|
||||||
|
end
|
||||||
|
def create_editor_options_pages
|
||||||
|
add_editor_options_page(Plugin2EditorOptionsPage::new)
|
||||||
|
@ep += 1
|
||||||
|
end
|
||||||
|
def create_config_pages
|
||||||
|
add_config_page(Plugin2ConfigPage::new)
|
||||||
|
@cp += 1
|
||||||
|
end
|
||||||
|
def pi
|
||||||
|
@pi
|
||||||
|
end
|
||||||
|
def ep
|
||||||
|
@ep
|
||||||
|
end
|
||||||
|
def cp
|
||||||
|
@cp
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def test_1
|
class LayPlugin_TestClass < TestBase
|
||||||
|
|
||||||
assert_equal(RBA::Plugin::AC_Global.to_s, "AC_Global")
|
def test_1
|
||||||
assert_equal(RBA::Plugin::AC_Any.to_s, "AC_Any")
|
|
||||||
assert_equal(RBA::Plugin::AC_Diagonal.to_s, "AC_Diagonal")
|
|
||||||
assert_equal(RBA::Plugin::AC_Horizontal.to_s, "AC_Horizontal")
|
|
||||||
assert_equal(RBA::Plugin::AC_Vertical.to_s, "AC_Vertical")
|
|
||||||
|
|
||||||
assert_equal(RBA::Plugin::ac_from_buttons(0), RBA::Plugin::AC_Global)
|
|
||||||
assert_equal(RBA::Plugin::ac_from_buttons(1), RBA::Plugin::AC_Ortho)
|
|
||||||
assert_equal(RBA::Plugin::ac_from_buttons(2), RBA::Plugin::AC_Diagonal)
|
|
||||||
|
|
||||||
begin
|
assert_equal(RBA::Plugin::AC_Global.to_s, "AC_Global")
|
||||||
|
assert_equal(RBA::Plugin::AC_Any.to_s, "AC_Any")
|
||||||
dpi = PluginFactory::new
|
assert_equal(RBA::Plugin::AC_Diagonal.to_s, "AC_Diagonal")
|
||||||
dpi2 = PluginFactory2::new
|
assert_equal(RBA::Plugin::AC_Horizontal.to_s, "AC_Horizontal")
|
||||||
|
assert_equal(RBA::Plugin::AC_Vertical.to_s, "AC_Vertical")
|
||||||
|
|
||||||
# Create a new layout
|
assert_equal(RBA::Plugin::ac_from_buttons(0), RBA::Plugin::AC_Global)
|
||||||
main_window = RBA::MainWindow.instance()
|
assert_equal(RBA::Plugin::ac_from_buttons(1), RBA::Plugin::AC_Ortho)
|
||||||
main_window.close_all
|
assert_equal(RBA::Plugin::ac_from_buttons(2), RBA::Plugin::AC_Diagonal)
|
||||||
main_window.create_layout(2)
|
|
||||||
|
|
||||||
pi = dpi.pi
|
begin
|
||||||
pi2 = dpi2.pi
|
|
||||||
|
|
||||||
# smoke test
|
|
||||||
pi.grab_mouse
|
|
||||||
pi.ungrab_mouse
|
|
||||||
pi.set_cursor(RBA::Cursor::Wait)
|
|
||||||
pi.add_edge_marker(RBA::DEdge::new)
|
|
||||||
pi.add_mouse_cursor(RBA::DPoint::new)
|
|
||||||
pi.clear_mouse_cursors
|
|
||||||
|
|
||||||
# virtual methods
|
dpi = PluginFactory::new
|
||||||
assert_equal(pi.has_tracking_position_test, false)
|
dpi2 = PluginFactory2::new
|
||||||
pi.clear_mouse_cursors
|
|
||||||
pi.add_mouse_cursor(RBA::DPoint::new(1, 2))
|
# Create a new layout
|
||||||
assert_equal(pi.has_tracking_position_test, true)
|
main_window = RBA::MainWindow.instance()
|
||||||
assert_equal(pi.tracking_position_test.to_s, "1,2")
|
main_window.close_all
|
||||||
pi.clear_mouse_cursors
|
main_window.create_layout(2)
|
||||||
assert_equal(pi.has_tracking_position_test, false)
|
|
||||||
|
|
||||||
assert_equal(pi2.has_tracking_position_test, false)
|
pi = dpi.pi
|
||||||
pi2.set_tp(RBA::DPoint::new(2, 3))
|
pi2 = dpi2.pi
|
||||||
assert_equal(pi2.has_tracking_position_test, true)
|
|
||||||
assert_equal(pi2.tracking_position_test.to_s, "2,3")
|
# smoke test
|
||||||
pi2.set_tp(nil)
|
pi.grab_mouse
|
||||||
assert_equal(pi2.has_tracking_position_test, false)
|
pi.ungrab_mouse
|
||||||
|
pi.set_cursor(RBA::Cursor::Wait)
|
||||||
|
pi.add_edge_marker(RBA::DEdge::new)
|
||||||
|
pi.add_mouse_cursor(RBA::DPoint::new)
|
||||||
|
pi.clear_mouse_cursors
|
||||||
|
|
||||||
assert_equal(dpi2.ep, 1)
|
# virtual methods
|
||||||
assert_equal(dpi2.cp, 1)
|
assert_equal(pi.has_tracking_position_test, false)
|
||||||
assert_equal(pi2.editor_options_pages.size, 1)
|
pi.clear_mouse_cursors
|
||||||
assert_equal(pi2.editor_options_pages[0].class.to_s, "Plugin2EditorOptionsPage")
|
pi.add_mouse_cursor(RBA::DPoint::new(1, 2))
|
||||||
|
assert_equal(pi.has_tracking_position_test, true)
|
||||||
|
assert_equal(pi.tracking_position_test.to_s, "1,2")
|
||||||
|
pi.clear_mouse_cursors
|
||||||
|
assert_equal(pi.has_tracking_position_test, false)
|
||||||
|
|
||||||
pi.configure_test("edit-grid", "0.0")
|
assert_equal(pi2.has_tracking_position_test, false)
|
||||||
assert_equal(pi.snap(RBA::DPoint::new(0.01, 0.02)).to_s, "0.01,0.02")
|
pi2.set_tp(RBA::DPoint::new(2, 3))
|
||||||
assert_equal(pi.snap(RBA::DVector::new(0.01, 0.02)).to_s, "0.01,0.02")
|
assert_equal(pi2.has_tracking_position_test, true)
|
||||||
pi.configure_test("edit-grid", "0.1")
|
assert_equal(pi2.tracking_position_test.to_s, "2,3")
|
||||||
assert_equal(pi.snap(RBA::DPoint::new(0.11, 0.18)).to_s, "0.1,0.2")
|
pi2.set_tp(nil)
|
||||||
assert_equal(pi.snap(RBA::DVector::new(0.11, 0.18)).to_s, "0.1,0.2")
|
assert_equal(pi2.has_tracking_position_test, false)
|
||||||
|
|
||||||
pi.configure_test("edit-connect-angle-mode", "ortho")
|
assert_equal(dpi2.ep, 1)
|
||||||
assert_equal(pi.snap(RBA::DPoint::new(1.5, 2.1), RBA::DPoint::new(1, 2), true).to_s, "1.5,2")
|
assert_equal(dpi2.cp, 1)
|
||||||
assert_equal(pi.snap(RBA::DPoint::new(1.5, 2.1), RBA::DPoint::new(1, 2), false).to_s, "1.5,2.1")
|
assert_equal(pi2.editor_options_pages.size, 1)
|
||||||
assert_equal(pi.snap(RBA::DPoint::new(1.5, 2.1), RBA::DPoint::new(1, 2), false, RBA::Plugin::AC_Ortho).to_s, "1.5,2")
|
assert_equal(pi2.editor_options_pages[0].class.to_s, "Plugin2EditorOptionsPage")
|
||||||
|
|
||||||
pi.configure_test("edit-connect-angle-mode", "ortho")
|
pi.configure_test("edit-grid", "0.0")
|
||||||
assert_equal(pi.snap(RBA::DVector::new(0.5, 2.1), true).to_s, "0,2.1")
|
assert_equal(pi.snap(RBA::DPoint::new(0.01, 0.02)).to_s, "0.01,0.02")
|
||||||
assert_equal(pi.snap(RBA::DVector::new(0.5, 2.1), false).to_s, "0.5,2.1")
|
assert_equal(pi.snap(RBA::DVector::new(0.01, 0.02)).to_s, "0.01,0.02")
|
||||||
assert_equal(pi.snap(RBA::DVector::new(0.5, 2.1), false, RBA::Plugin::AC_Ortho).to_s, "0,2.1")
|
pi.configure_test("edit-grid", "0.1")
|
||||||
|
assert_equal(pi.snap(RBA::DPoint::new(0.11, 0.18)).to_s, "0.1,0.2")
|
||||||
|
assert_equal(pi.snap(RBA::DVector::new(0.11, 0.18)).to_s, "0.1,0.2")
|
||||||
|
|
||||||
|
pi.configure_test("edit-connect-angle-mode", "ortho")
|
||||||
|
assert_equal(pi.snap(RBA::DPoint::new(1.5, 2.1), RBA::DPoint::new(1, 2), true).to_s, "1.5,2")
|
||||||
|
assert_equal(pi.snap(RBA::DPoint::new(1.5, 2.1), RBA::DPoint::new(1, 2), false).to_s, "1.5,2.1")
|
||||||
|
assert_equal(pi.snap(RBA::DPoint::new(1.5, 2.1), RBA::DPoint::new(1, 2), false, RBA::Plugin::AC_Ortho).to_s, "1.5,2")
|
||||||
|
|
||||||
|
pi.configure_test("edit-connect-angle-mode", "ortho")
|
||||||
|
assert_equal(pi.snap(RBA::DVector::new(0.5, 2.1), true).to_s, "0,2.1")
|
||||||
|
assert_equal(pi.snap(RBA::DVector::new(0.5, 2.1), false).to_s, "0.5,2.1")
|
||||||
|
assert_equal(pi.snap(RBA::DVector::new(0.5, 2.1), false, RBA::Plugin::AC_Ortho).to_s, "0,2.1")
|
||||||
|
|
||||||
|
ensure
|
||||||
|
main_window.close_all
|
||||||
|
dpi._destroy
|
||||||
|
dpi2._destroy
|
||||||
|
end
|
||||||
|
|
||||||
ensure
|
|
||||||
main_window.close_all
|
|
||||||
dpi._destroy
|
|
||||||
dpi2._destroy
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
# at least one test is needed
|
||||||
|
class LayPlugin_TestClass < TestBase
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
load("test_epilogue.rb")
|
load("test_epilogue.rb")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue