Upstreaming browser/ui/uikit_ui_util from iOS.
[chromium-blink-merge.git] / gpu / command_buffer / tests / gl_tests_main.cc
blob6ac571979c3333ba8b5850af05c2df4172b3cda4
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "base/at_exit.h"
6 #include "base/bind.h"
7 #include "base/command_line.h"
8 #include "base/message_loop/message_loop.h"
9 #if defined(OS_MACOSX)
10 #include "base/mac/scoped_nsautorelease_pool.h"
11 #endif
12 #include "base/test/launcher/unit_test_launcher.h"
13 #include "base/test/test_suite.h"
14 #include "gpu/command_buffer/client/gles2_lib.h"
15 #include "gpu/config/gpu_util.h"
16 #include "testing/gmock/include/gmock/gmock.h"
17 #include "ui/gl/gl_surface.h"
19 #if defined(OS_ANDROID)
20 #include "base/android/jni_android.h"
21 #include "ui/gl/android/gl_jni_registrar.h"
22 #endif
24 namespace {
26 int RunHelper(base::TestSuite* testSuite) {
27 #if defined(USE_OZONE)
28 base::MessageLoopForUI main_loop;
29 #else
30 base::MessageLoopForIO message_loop;
31 #endif
32 gfx::GLSurface::InitializeOneOff();
33 ::gles2::Initialize();
34 gpu::ApplyGpuDriverBugWorkarounds(base::CommandLine::ForCurrentProcess());
35 return testSuite->Run();
38 } // namespace
40 int main(int argc, char** argv) {
41 #if defined(OS_ANDROID)
42 ui::gl::android::RegisterJni(base::android::AttachCurrentThread());
43 #endif
44 base::TestSuite test_suite(argc, argv);
45 base::CommandLine::Init(argc, argv);
46 #if defined(OS_MACOSX)
47 base::mac::ScopedNSAutoreleasePool pool;
48 #endif
49 testing::InitGoogleMock(&argc, argv);
50 return base::LaunchUnitTestsSerially(
51 argc,
52 argv,
53 base::Bind(&RunHelper, base::Unretained(&test_suite)));