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