Skip to content

Commit

Permalink
Revert 270894 "Use real PlatformSupport in content unit tests"
Browse files Browse the repository at this point in the history
> Use real PlatformSupport in content unit tests
> 
> Once all pages are force composited by default, this allows these tests
> to not explode when trying to create GraphicsLayers because of a lack of
> Platform::compositorSupport.
> 
> BUG=none
> 
> Review URL: https://codereview.chromium.org/287043002

This test has caused leak errors on the mac valgrind bot:
http://build.chromium.org/p/chromium.memory.fyi/builders/Chromium%20Mac%20%28valgrind%29%282%29/builds/27964

TBR=enne@chromium.org

Review URL: https://codereview.chromium.org/284193006

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@270950 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
benwells@chromium.org committed May 16, 2014
1 parent 3c4f1f4 commit cee6a92
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 18 deletions.
24 changes: 12 additions & 12 deletions content/content_tests.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
'public/test/nested_message_pump_android.cc',
'public/test/nested_message_pump_android.h',
'test/layouttest_support.cc',
'test/mock_webclipboard_impl.cc',
'test/mock_webclipboard_impl.h',
'test/test_media_stream_client.cc',
'test/test_media_stream_client.h',
'test/test_video_frame_provider.cc',
Expand Down Expand Up @@ -171,8 +173,6 @@
'test/mock_keyboard_driver_win.h',
'test/mock_render_process.cc',
'test/mock_render_process.h',
'test/mock_webclipboard_impl.cc',
'test/mock_webclipboard_impl.h',
'test/mock_webframeclient.h',
'test/mock_weburlloader.cc',
'test/mock_weburlloader.h',
Expand Down Expand Up @@ -204,16 +204,8 @@
'test/test_render_view_host_factory.h',
'test/test_web_contents.cc',
'test/test_web_contents.h',
'test/test_webkit_platform_support.cc',
'test/test_webkit_platform_support.h',
'test/web_gesture_curve_mock.cc',
'test/web_gesture_curve_mock.h',
'test/webkit_support.cc',
'test/webkit_support.h',
'test/webkit_unit_test_support.cc',
'test/webkit_unit_test_support.h',
'test/web_layer_tree_view_impl_for_testing.cc',
'test/web_layer_tree_view_impl_for_testing.h',
'test/weburl_loader_mock.cc',
'test/weburl_loader_mock.h',
'test/weburl_loader_mock_factory.cc',
Expand Down Expand Up @@ -1356,8 +1348,6 @@
],
},
{
# TODO(enne): Remove this once dependencies in Blink
# point to test_support_content instead.
'target_name': 'content_webkit_unit_test_support',
'type': 'static_library',
'dependencies': [
Expand All @@ -1367,6 +1357,16 @@
'..',
],
'sources': [
'test/mock_webclipboard_impl.cc',
'test/mock_webclipboard_impl.h',
'test/test_webkit_platform_support.cc',
'test/test_webkit_platform_support.h',
'test/web_layer_tree_view_impl_for_testing.cc',
'test/web_layer_tree_view_impl_for_testing.h',
'test/webkit_support.cc',
'test/webkit_support.h',
'test/webkit_unit_test_support.cc',
'test/webkit_unit_test_support.h',
],
},
],
Expand Down
30 changes: 26 additions & 4 deletions content/public/test/unittest_test_suite.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,44 @@
#include "base/logging.h"
#include "base/rand_util.h"
#include "base/test/test_suite.h"
#if !defined(OS_IOS)
#include "content/test/test_webkit_platform_support.h"
#endif
#include "third_party/WebKit/public/platform/Platform.h"
#include "third_party/WebKit/public/web/WebKit.h"

namespace content {

#if !defined(OS_IOS)
// A stubbed out WebKit platform support impl.
class UnitTestTestSuite::UnitTestWebKitPlatformSupport
: public blink::Platform {
public:
UnitTestWebKitPlatformSupport() {}
virtual ~UnitTestWebKitPlatformSupport() {}
virtual void cryptographicallyRandomValues(unsigned char* buffer,
size_t length) OVERRIDE {
base::RandBytes(buffer, length);
}
virtual const unsigned char* getTraceCategoryEnabledFlag(
const char* categoryName) {
// Causes tracing macros to be disabled.
static const unsigned char kEnabled = 0;
return &kEnabled;
}
};
#endif // !OS_IOS

UnitTestTestSuite::UnitTestTestSuite(base::TestSuite* test_suite)
: test_suite_(test_suite) {
DCHECK(test_suite);
#if !defined(OS_IOS)
platform_support_.reset(new TestWebKitPlatformSupport);
webkit_platform_support_.reset(new UnitTestWebKitPlatformSupport);
blink::initialize(webkit_platform_support_.get());
#endif
}

UnitTestTestSuite::~UnitTestTestSuite() {
#if !defined(OS_IOS)
blink::shutdown();
#endif
}

int UnitTestTestSuite::Run() {
Expand Down
4 changes: 2 additions & 2 deletions content/public/test/unittest_test_suite.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ class TestSuite;
}

namespace content {
class TestWebKitPlatformSupport;

// A special test suite that also initializes WebKit once for all unittests.
// This is useful for two reasons:
Expand All @@ -32,7 +31,8 @@ class UnitTestTestSuite {
scoped_ptr<base::TestSuite> test_suite_;

#if !defined(OS_IOS)
scoped_ptr<TestWebKitPlatformSupport> platform_support_;
class UnitTestWebKitPlatformSupport;
scoped_ptr<UnitTestWebKitPlatformSupport> webkit_platform_support_;
#endif

DISALLOW_COPY_AND_ASSIGN(UnitTestTestSuite);
Expand Down

0 comments on commit cee6a92

Please sign in to comment.