Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1691)

Unified Diff: cc/test/run_all_unittests.cc

Issue 10905231: Enable cc_unittests in component build (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: mark WebThreadImplForMessageLoop ctor/dtor as exported Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/test/CCSchedulerTestCommon.h ('k') | webkit/glue/webthread_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/test/run_all_unittests.cc
diff --git a/cc/test/run_all_unittests.cc b/cc/test/run_all_unittests.cc
index d6c4ba09688c6533095c21652e1184b81bbfbca3..98152ba0c2deb2831d2959d531c683cc95e0a951 100644
--- a/cc/test/run_all_unittests.cc
+++ b/cc/test/run_all_unittests.cc
@@ -2,23 +2,72 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include <base/test/test_suite.h>
+#include "base/message_loop.h"
+#include "base/rand_util.h"
+#include "base/threading/thread_local_storage.h"
+#include "base/test/test_suite.h"
+#include "third_party/WebKit/Source/Platform/chromium/public/Platform.h"
+#include "webkit/compositor_bindings/web_compositor_support_impl.h"
+#include "webkit/glue/webthread_impl.h"
#include <gmock/gmock.h>
-#if defined(USE_LIBCC_FOR_COMPOSITOR)
-#include <webkit/support/webkit_support.h>
-#endif
+#include "base/debug/trace_event_impl.h"
+
+using webkit_glue::WebThreadImplForMessageLoop;
+
+class TestPlatform : public WebKit::Platform {
+ public:
+ virtual WebKit::WebCompositorSupport* compositorSupport() {
+ return &compositor_support_;
+ }
+
+ virtual void cryptographicallyRandomValues(
+ unsigned char* buffer, size_t length) {
+ base::RandBytes(buffer, length);
+ }
+
+ virtual WebKit::WebThread* createThread(const char* name) {
+ return new webkit_glue::WebThreadImpl(name);
+ }
+
+ virtual WebKit::WebThread* currentThread() {
+ webkit_glue::WebThreadImplForMessageLoop* thread =
+ static_cast<WebThreadImplForMessageLoop*>(current_thread_slot_.Get());
+ if (thread)
+ return (thread);
+
+ scoped_refptr<base::MessageLoopProxy> message_loop =
+ base::MessageLoopProxy::current();
+ if (!message_loop)
+ return NULL;
+
+ thread = new WebThreadImplForMessageLoop(message_loop);
+ current_thread_slot_.Set(thread);
+ return thread;
+ }
+
+ virtual double currentTime() {
+ return base::Time::Now().ToDoubleT();
+ }
+
+ virtual double monotonicallyIncreasingTime() {
+ return base::TimeTicks::Now().ToInternalValue() /
+ static_cast<double>(base::Time::kMicrosecondsPerSecond);
+ }
+
+ private:
+ base::ThreadLocalStorage::Slot current_thread_slot_;
+ webkit::WebCompositorSupportImpl compositor_support_;
+};
int main(int argc, char** argv) {
::testing::InitGoogleMock(&argc, argv);
TestSuite testSuite(argc, argv);
-#if defined(USE_LIBCC_FOR_COMPOSITOR)
- webkit_support::SetUpTestEnvironmentForUnitTests();
-#endif
+ TestPlatform platform;
+ MessageLoop message_loop;
+ WebKit::Platform::initialize(&platform);
int result = testSuite.Run();
-#if defined(USE_LIBCC_FOR_COMPOSITOR)
- webkit_support::TearDownTestEnvironment();
-#endif
+ WebKit::Platform::shutdown();
return result;
}
« no previous file with comments | « cc/test/CCSchedulerTestCommon.h ('k') | webkit/glue/webthread_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698