Commit 7aec44bd authored by Daniele Castagna's avatar Daniele Castagna Committed by Commit Bot

gpu: make gl_tests run on Ozone

gl_tests can't currently be run on ChromeOS devices since is missing
Ozone initialization.

This patch fixes that.
It can now be run on Chromebooks (with some failing tests).

Change-Id: I713633ccfc4b830ad99baf3566a3502205cde172
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1722972Reviewed-by: default avatarJonathan Backer <backer@chromium.org>
Commit-Queue: Daniele Castagna <dcastagna@chromium.org>
Cr-Commit-Position: refs/heads/master@{#681858}
parent 1d340590
......@@ -374,6 +374,10 @@ test("gl_tests") {
"//ui/gl/init",
]
if (use_ozone) {
deps += [ "//ui/ozone" ]
}
if (use_dawn) {
deps += [ "//third_party/dawn/src/dawn:libdawn" ]
}
......
......@@ -9,6 +9,7 @@
#include "base/message_loop/message_pump.h"
#include "base/task/single_thread_task_executor.h"
#include "base/test/launcher/unit_test_launcher.h"
#include "base/test/scoped_task_environment.h"
#include "base/test/test_suite.h"
#include "build/build_config.h"
#include "gpu/command_buffer/client/gles2_lib.h"
......@@ -20,33 +21,56 @@
#include "base/mac/scoped_nsautorelease_pool.h"
#endif
#if defined(USE_OZONE)
#include "ui/ozone/public/ozone_platform.h"
#endif
namespace {
int RunHelper(base::TestSuite* testSuite) {
base::FeatureList::InitializeInstance(std::string(), std::string());
class GlTestsSuite : public base::TestSuite {
public:
GlTestsSuite(int argc, char** argv) : base::TestSuite(argc, argv) {}
protected:
void Initialize() override {
base::TestSuite::Initialize();
base::FeatureList::InitializeInstance(std::string(), std::string());
scoped_task_environment_ =
std::make_unique<base::test::ScopedTaskEnvironment>(
base::test::ScopedTaskEnvironment::MainThreadType::UI);
#if defined(USE_OZONE)
base::SingleThreadTaskExecutor executor(base::MessagePump::Type::UI);
#else
base::SingleThreadTaskExecutor executor(base::MessagePump::Type::IO);
// Make Ozone run in single-process mode.
ui::OzonePlatform::InitParams params;
params.single_process = true;
params.using_mojo = true;
// This initialization must be done after ScopedTaskEnvironment has
// initialized the UI thread.
ui::OzonePlatform::InitializeForUI(params);
ui::OzonePlatform::InitializeForGPU(params);
#endif
gpu::GLTestHelper::InitializeGLDefault();
::gles2::Initialize();
return testSuite->Run();
}
}
private:
std::unique_ptr<base::test::ScopedTaskEnvironment> scoped_task_environment_;
};
} // namespace
int main(int argc, char** argv) {
base::TestSuite test_suite(argc, argv);
base::CommandLine::Init(argc, argv);
mojo::core::Init();
GlTestsSuite gl_tests_suite(argc, argv);
#if defined(OS_MACOSX)
base::mac::ScopedNSAutoreleasePool pool;
#endif
testing::InitGoogleMock(&argc, argv);
return base::LaunchUnitTestsSerially(
argc, argv, base::BindOnce(&RunHelper, base::Unretained(&test_suite)));
argc, argv,
base::BindOnce(&GlTestsSuite::Run, base::Unretained(&gl_tests_suite)));
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment