OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/at_exit.h" | 5 #include "base/at_exit.h" |
6 #include "base/bind.h" | 6 #include "base/bind.h" |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/test/launcher/unit_test_launcher.h" | 8 #include "base/test/launcher/unit_test_launcher.h" |
9 #include "base/test/test_suite.h" | 9 #include "base/test/test_suite.h" |
10 #include "testing/gmock/include/gmock/gmock.h" | 10 #include "testing/gmock/include/gmock/gmock.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
12 #include "ui/gl/gl_implementation.h" | 12 #include "ui/gl/gl_implementation.h" |
13 #include "ui/gl/gl_mock.h" | 13 #include "ui/gl/gl_mock.h" |
| 14 #include "ui/gl/gl_surface.h" |
14 | 15 |
15 namespace { | 16 namespace { |
16 | 17 |
17 class NoAtExitBaseTestSuite : public base::TestSuite { | 18 class NoAtExitBaseTestSuite : public base::TestSuite { |
18 public: | 19 public: |
19 NoAtExitBaseTestSuite(int argc, char** argv) | 20 NoAtExitBaseTestSuite(int argc, char** argv) |
20 : base::TestSuite(argc, argv, false) { | 21 : base::TestSuite(argc, argv, false) { |
21 } | 22 } |
| 23 |
| 24 virtual void Initialize() OVERRIDE { |
| 25 base::TestSuite::Initialize(); |
| 26 gfx::SetGLGetProcAddressProc(gfx::MockGLInterface::GetGLProcAddress); |
| 27 gfx::GLSurface::InitializeOneOffWithMockBindingsForTests(); |
| 28 gfx::GLSurface::InitializeDynamicMockBindingsForTests(NULL); |
| 29 } |
22 }; | 30 }; |
23 | 31 |
24 int RunTestSuite(int argc, char** argv) { | 32 int RunTestSuite(int argc, char** argv) { |
25 return NoAtExitBaseTestSuite(argc, argv).Run(); | 33 return NoAtExitBaseTestSuite(argc, argv).Run(); |
26 } | 34 } |
27 | 35 |
28 } // namespace | 36 } // namespace |
29 | 37 |
30 int main(int argc, char** argv) { | 38 int main(int argc, char** argv) { |
31 // On Android, AtExitManager is created in | 39 // On Android, AtExitManager is created in |
32 // testing/android/native_test_wrapper.cc before main() is called. | 40 // testing/android/native_test_wrapper.cc before main() is called. |
33 // The same thing is also done in base/test/test_suite.cc | 41 // The same thing is also done in base/test/test_suite.cc |
34 #if !defined(OS_ANDROID) | 42 #if !defined(OS_ANDROID) |
35 base::AtExitManager exit_manager; | 43 base::AtExitManager exit_manager; |
36 #endif | 44 #endif |
37 CommandLine::Init(argc, argv); | 45 CommandLine::Init(argc, argv); |
38 gfx::SetGLGetProcAddressProc(gfx::MockGLInterface::GetGLProcAddress); | |
39 gfx::InitializeStaticGLBindings(gfx::kGLImplementationMockGL); | |
40 gfx::InitializeDynamicGLBindings(gfx::kGLImplementationMockGL, NULL); | |
41 testing::InitGoogleMock(&argc, argv); | 46 testing::InitGoogleMock(&argc, argv); |
42 return base::LaunchUnitTests(argc, | 47 return base::LaunchUnitTests(argc, |
43 argv, | 48 argv, |
44 base::Bind(&RunTestSuite, argc, argv)); | 49 base::Bind(&RunTestSuite, argc, argv)); |
45 } | 50 } |
OLD | NEW |