| 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 "content/public/test/unittest_test_suite.h" | 5 #include "content/public/test/unittest_test_suite.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/rand_util.h" | 8 #include "base/rand_util.h" |
| 9 #include "base/test/test_suite.h" | 9 #include "base/test/test_suite.h" |
| 10 #include "third_party/WebKit/public/platform/Platform.h" | 10 #include "third_party/WebKit/public/platform/Platform.h" |
| 11 #include "third_party/WebKit/public/web/WebKit.h" | 11 #include "third_party/WebKit/public/web/WebKit.h" |
| 12 #include "ui/gl/gl_surface.h" |
| 12 | 13 |
| 13 namespace content { | 14 namespace content { |
| 14 | 15 |
| 15 #if !defined(OS_IOS) | 16 #if !defined(OS_IOS) |
| 16 // A stubbed out WebKit platform support impl. | 17 // A stubbed out WebKit platform support impl. |
| 17 class UnitTestTestSuite::UnitTestWebKitPlatformSupport | 18 class UnitTestTestSuite::UnitTestWebKitPlatformSupport |
| 18 : public blink::Platform { | 19 : public blink::Platform { |
| 19 public: | 20 public: |
| 20 UnitTestWebKitPlatformSupport() {} | 21 UnitTestWebKitPlatformSupport() {} |
| 21 virtual ~UnitTestWebKitPlatformSupport() {} | 22 virtual ~UnitTestWebKitPlatformSupport() {} |
| 22 virtual void cryptographicallyRandomValues(unsigned char* buffer, | 23 virtual void cryptographicallyRandomValues(unsigned char* buffer, |
| 23 size_t length) OVERRIDE { | 24 size_t length) OVERRIDE { |
| 24 base::RandBytes(buffer, length); | 25 base::RandBytes(buffer, length); |
| 25 } | 26 } |
| 26 virtual const unsigned char* getTraceCategoryEnabledFlag( | 27 virtual const unsigned char* getTraceCategoryEnabledFlag( |
| 27 const char* categoryName) { | 28 const char* categoryName) { |
| 28 // Causes tracing macros to be disabled. | 29 // Causes tracing macros to be disabled. |
| 29 static const unsigned char kEnabled = 0; | 30 static const unsigned char kEnabled = 0; |
| 30 return &kEnabled; | 31 return &kEnabled; |
| 31 } | 32 } |
| 32 }; | 33 }; |
| 33 #endif // !OS_IOS | 34 #endif // !OS_IOS |
| 34 | 35 |
| 35 UnitTestTestSuite::UnitTestTestSuite(base::TestSuite* test_suite) | 36 UnitTestTestSuite::UnitTestTestSuite(base::TestSuite* test_suite) |
| 36 : test_suite_(test_suite) { | 37 : test_suite_(test_suite) { |
| 37 DCHECK(test_suite); | 38 DCHECK(test_suite); |
| 38 #if !defined(OS_IOS) | 39 #if !defined(OS_IOS) |
| 40 gfx::GLSurface::InitializeOneOffForTests(); |
| 41 |
| 39 webkit_platform_support_.reset(new UnitTestWebKitPlatformSupport); | 42 webkit_platform_support_.reset(new UnitTestWebKitPlatformSupport); |
| 40 blink::initialize(webkit_platform_support_.get()); | 43 blink::initialize(webkit_platform_support_.get()); |
| 41 #endif | 44 #endif |
| 42 } | 45 } |
| 43 | 46 |
| 44 UnitTestTestSuite::~UnitTestTestSuite() { | 47 UnitTestTestSuite::~UnitTestTestSuite() { |
| 45 #if !defined(OS_IOS) | 48 #if !defined(OS_IOS) |
| 46 blink::shutdown(); | 49 blink::shutdown(); |
| 47 #endif | 50 #endif |
| 48 } | 51 } |
| 49 | 52 |
| 50 int UnitTestTestSuite::Run() { | 53 int UnitTestTestSuite::Run() { |
| 51 return test_suite_->Run(); | 54 return test_suite_->Run(); |
| 52 } | 55 } |
| 53 | 56 |
| 54 } // namespace content | 57 } // namespace content |
| OLD | NEW |