Browse Source

Visual tests: Set test index to load initially using command line argument

Michael Ragazzon 4 years ago
parent
commit
14d6a29078

+ 3 - 1
Tests/Source/VisualTests/TestNavigator.cpp

@@ -41,7 +41,7 @@
 constexpr int iteration_wait_frame_count = 2;
 constexpr int iteration_wait_frame_count = 2;
 
 
 
 
-TestNavigator::TestNavigator(ShellRenderInterfaceOpenGL* shell_renderer, Rml::Context* context, TestViewer* viewer, TestSuiteList test_suites)
+TestNavigator::TestNavigator(ShellRenderInterfaceOpenGL* shell_renderer, Rml::Context* context, TestViewer* viewer, TestSuiteList test_suites, int start_index)
 	: shell_renderer(shell_renderer), context(context), viewer(viewer), test_suites(std::move(test_suites))
 	: shell_renderer(shell_renderer), context(context), viewer(viewer), test_suites(std::move(test_suites))
 {
 {
 	RMLUI_ASSERT(context);
 	RMLUI_ASSERT(context);
@@ -50,6 +50,8 @@ TestNavigator::TestNavigator(ShellRenderInterfaceOpenGL* shell_renderer, Rml::Co
 	context->GetRootElement()->AddEventListener(Rml::EventId::Keydown, this);
 	context->GetRootElement()->AddEventListener(Rml::EventId::Keydown, this);
 	context->GetRootElement()->AddEventListener(Rml::EventId::Textinput, this);
 	context->GetRootElement()->AddEventListener(Rml::EventId::Textinput, this);
 	context->GetRootElement()->AddEventListener(Rml::EventId::Change, this);
 	context->GetRootElement()->AddEventListener(Rml::EventId::Change, this);
+	if(start_index > 0)
+		CurrentSuite().SetIndex(start_index);
 	LoadActiveTest();
 	LoadActiveTest();
 }
 }
 
 

+ 1 - 1
Tests/Source/VisualTests/TestNavigator.h

@@ -39,7 +39,7 @@ class ShellRenderInterfaceOpenGL;
 
 
 class TestNavigator : public Rml::EventListener {
 class TestNavigator : public Rml::EventListener {
 public:
 public:
-	TestNavigator(ShellRenderInterfaceOpenGL* shell_renderer, Rml::Context* context, TestViewer* viewer, TestSuiteList test_suites);
+	TestNavigator(ShellRenderInterfaceOpenGL* shell_renderer, Rml::Context* context, TestViewer* viewer, TestSuiteList test_suites, int start_index);
 	~TestNavigator();
 	~TestNavigator();
 
 
 	void Update();
 	void Update();

+ 10 - 6
Tests/Source/VisualTests/main.cpp

@@ -61,21 +61,25 @@ void GameLoop()
 
 
 #if defined RMLUI_PLATFORM_WIN32
 #if defined RMLUI_PLATFORM_WIN32
 #include <windows.h>
 #include <windows.h>
-int APIENTRY WinMain(HINSTANCE RMLUI_UNUSED_PARAMETER(instance_handle), HINSTANCE RMLUI_UNUSED_PARAMETER(previous_instance_handle), char* RMLUI_UNUSED_PARAMETER(command_line), int RMLUI_UNUSED_PARAMETER(command_show))
+int APIENTRY WinMain(HINSTANCE RMLUI_UNUSED_PARAMETER(instance_handle), HINSTANCE RMLUI_UNUSED_PARAMETER(previous_instance_handle), char* command_line, int RMLUI_UNUSED_PARAMETER(command_show))
 #else
 #else
-int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv))
+int main(int argc, char** argv)
 #endif
 #endif
 {
 {
+	int load_test_case_index = -1;
+
 #ifdef RMLUI_PLATFORM_WIN32
 #ifdef RMLUI_PLATFORM_WIN32
 	RMLUI_UNUSED(instance_handle);
 	RMLUI_UNUSED(instance_handle);
 	RMLUI_UNUSED(previous_instance_handle);
 	RMLUI_UNUSED(previous_instance_handle);
-	RMLUI_UNUSED(command_line);
 	RMLUI_UNUSED(command_show);
 	RMLUI_UNUSED(command_show);
+
+	load_test_case_index = std::atoi(command_line) - 1;
 #else
 #else
-	RMLUI_UNUSED(argc);
-	RMLUI_UNUSED(argv);
+	if (argc > 1)
+		load_test_case_index = std::atoi(argv[1]) - 1;
 #endif
 #endif
 
 
+
 	int window_width = 1500;
 	int window_width = 1500;
 	int window_height = 800;
 	int window_height = 800;
 
 
@@ -137,7 +141,7 @@ int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv))
 
 
 		TestViewer viewer(context);
 		TestViewer viewer(context);
 
 
-		TestNavigator navigator(shell_renderer, context, &viewer, std::move(test_suites));
+		TestNavigator navigator(shell_renderer, context, &viewer, std::move(test_suites), load_test_case_index);
 		g_navigator = &navigator;
 		g_navigator = &navigator;
 
 
 		Shell::EventLoop(GameLoop);
 		Shell::EventLoop(GameLoop);