~widelands-dev/widelands/toolbar-dropdown-menus

« back to all changes in this revision

Viewing changes to test/maps/plain.wmf/scripting/test_ui.lua

  • Committer: GunChleoc
  • Date: 2019-08-10 07:19:04 UTC
  • Revision ID: fios@foramnagaidhlig.net-20190810071904-8fxtzw1vsd0c899j
Fix highlighting via Lua and test for debug builds.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
local function open_and_close_sound_options(dropdown)
 
1
local function open_and_close_sound_options(dropdown, is_debug_build)
2
2
   sleep(100)
3
3
 
4
4
   -- Test out-of-range selection in dropdown
10
10
   end)
11
11
 
12
12
   -- Test selecting an item in the dropdown
13
 
   dropdown:highlight_item(1)
 
13
   if (is_debug_build) then
 
14
      dropdown:highlight_item(2)
 
15
   else
 
16
      dropdown:highlight_item(1)
 
17
   end
14
18
   assert_nil(wl.ui.MapView().windows.sound_options_menu, "Sound options window should not have been there yet")
15
19
 
16
20
   dropdown:select()
37
41
   local dropdown = dropdowns["dropdown_menu_main"]
38
42
   assert_not_nil(dropdown, "Failed to find main menu dropdown")
39
43
 
 
44
   local is_debug_build = dropdown.no_of_items == 4
 
45
 
40
46
   -- Selecting from closed dropdown should fail silently
41
47
   dropdown:select()
42
48
 
43
49
   -- Validate selection without opening
44
 
   open_and_close_sound_options(dropdown);
 
50
   open_and_close_sound_options(dropdown, is_debug_build);
45
51
 
46
52
   -- Validate selection with opening
47
53
   dropdown:open()
48
54
   sleep(100)
49
 
   open_and_close_sound_options(dropdown);
 
55
   open_and_close_sound_options(dropdown, is_debug_build);
50
56
 
51
57
   -- Exit by dropdown
52
58
   local dropdown = dropdowns["dropdown_menu_main"]
53
 
   dropdown:highlight_item(3)
 
59
      if (is_debug_build) then
 
60
      dropdown:highlight_item(4)
 
61
   else
 
62
      dropdown:highlight_item(3)
 
63
   end
54
64
   dropdown:select()
55
65
 
56
66
   local message_box = wl.ui.MapView().windows["message_box"]