OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #include "base/bind.h" | |
6 #include "base/message_loop/message_loop.h" | |
7 #if defined(OS_MACOSX) | |
8 #include "base/mac/scoped_nsautorelease_pool.h" | |
9 #endif | |
10 #include "base/test/launcher/unit_test_launcher.h" | |
11 #include "base/test/test_suite.h" | |
12 #include "gpu/gles2_conform_support/egl/test_support.h" | |
13 #include "testing/gmock/include/gmock/gmock.h" | |
14 | |
15 // This file implements the main entry point for tests for command_buffer_gles2, | |
16 // the mode of command buffer where the code is compiled as a standalone dynamic | |
17 // library and exposed through EGL API. | |
18 namespace { | |
19 | |
20 int RunHelper(base::TestSuite* testSuite) { | |
21 #if defined(USE_OZONE) | |
22 base::MessageLoopForUI main_loop; | |
23 #else | |
24 base::MessageLoopForIO message_loop; | |
25 #endif | |
26 return testSuite->Run(); | |
27 } | |
28 | |
29 } // namespace | |
30 | |
31 int main(int argc, char** argv) { | |
32 // NOTE: we initialize globals through TestSuite constructor or through JNI | |
33 // library registration process on Android. | |
34 | |
35 // However, when the system is compiled with component build, | |
36 // command_buffer_gles2 library and this test runner share the globals, such | |
37 // as AtExitManager and JVM references. When command_buffer_gles2 is run with | |
38 // the test runner, the globals may be populated. Any other app linking to | |
39 // command_buffer_gles2 of course can not provide the globals. | |
40 | |
41 // When the system is compiled without component build, command_buffer_gles2 | |
42 // gets its own globals, while the test runner gets its own. The runner | |
43 // initialize different global variables than the ones command_buffer_gles2 | |
44 // library uses. For example, there should be a global AtExitManager for the | |
45 // test runner, and there should be a global AtExitManager that the library | |
46 // uses. Similarly, if the test runner would use JNI, it should have global | |
47 // reference to the JNI environent. If the command_buffer_gles2 library would | |
48 // use JNI, it should have its own global reference to the JNI that always | |
49 // remains null. The reference of the library should always stay null, since | |
50 // JNI is not part of command_buffer_gles2 exported API (EGL API), and thus | |
51 // there is no way for the client of the library to populate the JNI | |
52 // pointer. The client may not even be a Java app. | |
53 | |
54 // We signify that the globals have been initialized when running | |
55 // the component build. | |
56 #if defined(COMPONENT_BUILD) | |
57 g_command_buffer_gles_has_atexit_manager = true; | |
58 #endif | |
59 | |
60 base::TestSuite test_suite(argc, argv); | |
61 #if defined(OS_MACOSX) | |
62 base::mac::ScopedNSAutoreleasePool pool; | |
63 #endif | |
64 testing::InitGoogleMock(&argc, argv); | |
65 return base::LaunchUnitTestsSerially( | |
66 argc, argv, base::Bind(&RunHelper, base::Unretained(&test_suite))); | |
67 } | |
OLD | NEW |