summaryrefslogtreecommitdiffstats
path: root/ui/compositor/test
diff options
context:
space:
mode:
Diffstat (limited to 'ui/compositor/test')
-rw-r--r--ui/compositor/test/compositor_test_support.cc58
-rw-r--r--ui/compositor/test/compositor_test_support.h21
-rw-r--r--ui/compositor/test/test_compositor_host.h34
-rw-r--r--ui/compositor/test/test_compositor_host_linux.cc104
-rw-r--r--ui/compositor/test/test_compositor_host_mac.mm153
-rw-r--r--ui/compositor/test/test_compositor_host_win.cc67
-rw-r--r--ui/compositor/test/test_layer_animation_delegate.cc62
-rw-r--r--ui/compositor/test/test_layer_animation_delegate.h44
-rw-r--r--ui/compositor/test/test_layer_animation_observer.cc41
-rw-r--r--ui/compositor/test/test_layer_animation_observer.h61
-rw-r--r--ui/compositor/test/test_suite.cc39
-rw-r--r--ui/compositor/test/test_suite.h29
-rw-r--r--ui/compositor/test/test_utils.cc28
-rw-r--r--ui/compositor/test/test_utils.h22
14 files changed, 763 insertions, 0 deletions
diff --git a/ui/compositor/test/compositor_test_support.cc b/ui/compositor/test/compositor_test_support.cc
new file mode 100644
index 0000000..6134f54
--- /dev/null
+++ b/ui/compositor/test/compositor_test_support.cc
@@ -0,0 +1,58 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/compositor/test/compositor_test_support.h"
+
+#include "base/compiler_specific.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h"
+#include "webkit/glue/webkitplatformsupport_impl.h"
+
+namespace ui {
+
+class CompositorTestPlatformSupport:
+ public NON_EXPORTED_BASE(webkit_glue::WebKitPlatformSupportImpl) {
+ public:
+ virtual string16 GetLocalizedString(int message_id) OVERRIDE {
+ return string16();
+ }
+
+ virtual base::StringPiece GetDataResource(int resource_id) OVERRIDE {
+ return base::StringPiece();
+ }
+
+ virtual void GetPlugins(
+ bool refresh, std::vector<webkit::WebPluginInfo>* plugins) OVERRIDE {
+ }
+
+ virtual webkit_glue::ResourceLoaderBridge* CreateResourceLoader(
+ const webkit_glue::ResourceLoaderBridge::RequestInfo& request_info)
+ OVERRIDE {
+ NOTREACHED();
+ return NULL;
+ }
+
+ virtual webkit_glue::WebSocketStreamHandleBridge* CreateWebSocketBridge(
+ WebKit::WebSocketStreamHandle* handle,
+ webkit_glue::WebSocketStreamHandleDelegate* delegate) OVERRIDE {
+ NOTREACHED();
+ return NULL;
+ }
+};
+
+static CompositorTestPlatformSupport* g_webkit_support;
+
+void CompositorTestSupport::Initialize() {
+ DCHECK(!g_webkit_support);
+ g_webkit_support = new CompositorTestPlatformSupport;
+ WebKit::initialize(g_webkit_support);
+}
+
+void CompositorTestSupport::Terminate() {
+ DCHECK(g_webkit_support);
+ WebKit::shutdown();
+ delete g_webkit_support;
+ g_webkit_support = NULL;
+}
+
+} // namespace ui
diff --git a/ui/compositor/test/compositor_test_support.h b/ui/compositor/test/compositor_test_support.h
new file mode 100644
index 0000000..7db9f51
--- /dev/null
+++ b/ui/compositor/test/compositor_test_support.h
@@ -0,0 +1,21 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_GFX_COMPOSITOR_TEST_TEST_SUPPORT_H_
+#define UI_GFX_COMPOSITOR_TEST_TEST_SUPPORT_H_
+#pragma once
+
+namespace ui {
+
+class CompositorTestSupport {
+ public:
+ // Called by programs that want to use a real compositor,
+ // but skip the typical initialization of browser_main.cc.
+ static void Initialize();
+ static void Terminate();
+};
+
+} // namespace ui
+
+#endif // UI_GFX_COMPOSITOR_TEST_TEST_SUPPORT_H_
diff --git a/ui/compositor/test/test_compositor_host.h b/ui/compositor/test/test_compositor_host.h
new file mode 100644
index 0000000..5cee7e3
--- /dev/null
+++ b/ui/compositor/test/test_compositor_host.h
@@ -0,0 +1,34 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_GFX_COMPOSITOR_TEST_TEST_COMPOSITOR_HOST_H_
+#define UI_GFX_COMPOSITOR_TEST_TEST_COMPOSITOR_HOST_H_
+#pragma once
+
+#include "base/message_loop.h"
+
+namespace gfx {
+class Rect;
+}
+
+namespace ui {
+
+class Compositor;
+
+class TestCompositorHost {
+ public:
+ virtual ~TestCompositorHost() {}
+
+ // Creates a new TestCompositorHost. The caller owns the returned value.
+ static TestCompositorHost* Create(const gfx::Rect& bounds);
+
+ // Shows the TestCompositorHost.
+ virtual void Show() = 0;
+
+ virtual ui::Compositor* GetCompositor() = 0;
+};
+
+} // namespace ui
+
+#endif // UI_GFX_COMPOSITOR_TEST_TEST_COMPOSITOR_HOST_H_
diff --git a/ui/compositor/test/test_compositor_host_linux.cc b/ui/compositor/test/test_compositor_host_linux.cc
new file mode 100644
index 0000000..0359723
--- /dev/null
+++ b/ui/compositor/test/test_compositor_host_linux.cc
@@ -0,0 +1,104 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/compositor/test/test_compositor_host.h"
+
+#include "base/basictypes.h"
+#include "base/bind.h"
+#include "base/compiler_specific.h"
+#include "base/logging.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
+#include "ui/base/x/x11_util.h"
+#include "ui/compositor/compositor.h"
+#include "ui/gfx/rect.h"
+
+#include <X11/Xlib.h>
+
+namespace ui {
+
+class TestCompositorHostLinux : public TestCompositorHost,
+ public CompositorDelegate {
+ public:
+ TestCompositorHostLinux(const gfx::Rect& bounds);
+ virtual ~TestCompositorHostLinux();
+
+ private:
+ // Overridden from TestCompositorHost:
+ virtual void Show() OVERRIDE;
+ virtual ui::Compositor* GetCompositor() OVERRIDE;
+
+ // Overridden from CompositorDelegate:
+ virtual void ScheduleDraw() OVERRIDE;
+
+ void Draw();
+
+ gfx::Rect bounds_;
+
+ scoped_ptr<ui::Compositor> compositor_;
+
+ XID window_;
+
+ base::WeakPtrFactory<TestCompositorHostLinux> method_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(TestCompositorHostLinux);
+};
+
+TestCompositorHostLinux::TestCompositorHostLinux(const gfx::Rect& bounds)
+ : bounds_(bounds),
+ ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) {
+}
+
+TestCompositorHostLinux::~TestCompositorHostLinux() {
+}
+
+void TestCompositorHostLinux::Show() {
+ Display* display = base::MessagePumpForUI::GetDefaultXDisplay();
+ XSetWindowAttributes swa;
+ swa.event_mask = StructureNotifyMask | ExposureMask;
+ swa.override_redirect = True;
+ window_ = XCreateWindow(
+ display,
+ RootWindow(display, DefaultScreen(display)), // parent
+ bounds_.x(), bounds_.y(), bounds_.width(), bounds_.height(),
+ 0, // border width
+ CopyFromParent, // depth
+ InputOutput,
+ CopyFromParent, // visual
+ CWEventMask | CWOverrideRedirect, &swa);
+ XMapWindow(display, window_);
+
+ while (1) {
+ XEvent event;
+ XNextEvent(display, &event);
+ if (event.type == MapNotify && event.xmap.window == window_)
+ break;
+ }
+ compositor_.reset(new ui::Compositor(this, window_, bounds_.size()));
+}
+
+ui::Compositor* TestCompositorHostLinux::GetCompositor() {
+ return compositor_.get();
+}
+
+void TestCompositorHostLinux::ScheduleDraw() {
+ if (!method_factory_.HasWeakPtrs()) {
+ MessageLoopForUI::current()->PostTask(
+ FROM_HERE,
+ base::Bind(&TestCompositorHostLinux::Draw,
+ method_factory_.GetWeakPtr()));
+ }
+}
+
+void TestCompositorHostLinux::Draw() {
+ if (compositor_.get())
+ compositor_->Draw(false);
+}
+
+// static
+TestCompositorHost* TestCompositorHost::Create(const gfx::Rect& bounds) {
+ return new TestCompositorHostLinux(bounds);
+}
+
+} // namespace ui
diff --git a/ui/compositor/test/test_compositor_host_mac.mm b/ui/compositor/test/test_compositor_host_mac.mm
new file mode 100644
index 0000000..3d237aa
--- /dev/null
+++ b/ui/compositor/test/test_compositor_host_mac.mm
@@ -0,0 +1,153 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/compositor/test/test_compositor_host.h"
+
+#import <AppKit/NSApplication.h>
+#import <AppKit/NSOpenGL.h>
+#import <AppKit/NSView.h>
+#import <AppKit/NSWindow.h>
+#import <Foundation/NSAutoreleasePool.h>
+
+#include "base/compiler_specific.h"
+#include "base/memory/scoped_nsobject.h"
+#include "base/memory/scoped_ptr.h"
+#include "ui/compositor/compositor.h"
+#include "ui/gfx/rect.h"
+
+// AcceleratedTestView provides an NSView class that delegates drawing to a
+// ui::Compositor delegate, setting up the NSOpenGLContext as required.
+@interface AcceleratedTestView : NSView {
+ ui::Compositor* compositor_;
+}
+// Designated initializer.
+-(id)init;
+-(void)setCompositor:(ui::Compositor*)compositor;
+@end
+
+@implementation AcceleratedTestView
+-(id)init {
+ // The frame will be resized when reparented into the window's view hierarchy.
+ self = [super initWithFrame:NSZeroRect];
+ return self;
+}
+
+-(void)setCompositor:(ui::Compositor*)compositor {
+ compositor_ = compositor;
+}
+
+- (void)drawRect:(NSRect)rect {
+ DCHECK(compositor_) << "Drawing with no compositor set.";
+ compositor_->Draw(false);
+}
+@end
+
+namespace ui {
+
+// Tests that use Objective-C memory semantics need to have a top-level
+// NSAutoreleasePool set up and initialized prior to execution and drained upon
+// exit. The tests will leak otherwise.
+class FoundationHost {
+ protected:
+ FoundationHost() {
+ pool_ = [[NSAutoreleasePool alloc] init];
+ }
+ virtual ~FoundationHost() {
+ [pool_ drain];
+ }
+
+ private:
+ NSAutoreleasePool* pool_;
+ DISALLOW_COPY_AND_ASSIGN(FoundationHost);
+};
+
+// Tests that use the AppKit framework need to have the NSApplication
+// initialized prior to doing anything with display objects such as windows,
+// views, or controls.
+class AppKitHost : public FoundationHost {
+ protected:
+ AppKitHost() {
+ [NSApplication sharedApplication];
+ }
+ virtual ~AppKitHost() {
+ }
+ private:
+ DISALLOW_COPY_AND_ASSIGN(AppKitHost);
+};
+
+// TestCompositorHostMac provides a window surface and a coordinated compositor
+// for use in the compositor unit tests.
+class TestCompositorHostMac : public TestCompositorHost,
+ public CompositorDelegate,
+ public AppKitHost {
+ public:
+ TestCompositorHostMac(const gfx::Rect& bounds);
+ virtual ~TestCompositorHostMac();
+
+ private:
+ // TestCompositorHost:
+ virtual void Show() OVERRIDE;
+ virtual ui::Compositor* GetCompositor() OVERRIDE;
+
+ // CompositorDelegate:
+ virtual void ScheduleDraw() OVERRIDE;
+
+ gfx::Rect bounds_;
+ scoped_ptr<ui::Compositor> compositor_;
+
+ // Owned. Released when window is closed.
+ NSWindow* window_;
+
+ DISALLOW_COPY_AND_ASSIGN(TestCompositorHostMac);
+};
+
+TestCompositorHostMac::TestCompositorHostMac(const gfx::Rect& bounds)
+ : bounds_(bounds), window_(nil) {
+}
+
+TestCompositorHostMac::~TestCompositorHostMac() {
+ // Release reference to |compositor_|. Important because the |compositor_|
+ // holds |this| as its delegate, so that reference must be removed here.
+ [[window_ contentView] setCompositor:NULL];
+ [window_ setContentView:nil];
+
+ [window_ orderOut:nil];
+ [window_ close];
+}
+
+void TestCompositorHostMac::Show() {
+ DCHECK(!window_);
+ window_ = [[NSWindow alloc]
+ initWithContentRect:NSMakeRect(bounds_.x(),
+ bounds_.y(),
+ bounds_.width(),
+ bounds_.height())
+ styleMask:NSBorderlessWindowMask
+ backing:NSBackingStoreBuffered
+ defer:NO];
+ scoped_nsobject<AcceleratedTestView> view([[AcceleratedTestView alloc] init]);
+ compositor_.reset(new ui::Compositor(this, view, bounds_.size()));
+ [view setCompositor:compositor_.get()];
+ [window_ setContentView:view];
+ [window_ orderFront:nil];
+}
+
+ui::Compositor* TestCompositorHostMac::GetCompositor() {
+ return compositor_.get();
+}
+
+void TestCompositorHostMac::ScheduleDraw() {
+ if (!compositor_.get())
+ return;
+
+ // Force display now.
+ [window_ display];
+}
+
+// static
+TestCompositorHost* TestCompositorHost::Create(const gfx::Rect& bounds) {
+ return new TestCompositorHostMac(bounds);
+}
+
+} // namespace ui
diff --git a/ui/compositor/test/test_compositor_host_win.cc b/ui/compositor/test/test_compositor_host_win.cc
new file mode 100644
index 0000000..8e0c4f2
--- /dev/null
+++ b/ui/compositor/test/test_compositor_host_win.cc
@@ -0,0 +1,67 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/compositor/test/test_compositor_host.h"
+
+#include "base/compiler_specific.h"
+#include "base/memory/scoped_ptr.h"
+#include "ui/base/win/window_impl.h"
+#include "ui/compositor/compositor.h"
+
+namespace ui {
+
+class TestCompositorHostWin : public TestCompositorHost,
+ public WindowImpl,
+ public CompositorDelegate {
+ public:
+ TestCompositorHostWin(const gfx::Rect& bounds) {
+ Init(NULL, bounds);
+ compositor_.reset(new ui::Compositor(this, hwnd(), GetSize()));
+ }
+
+ virtual ~TestCompositorHostWin() {
+ DestroyWindow(hwnd());
+ }
+
+ // Overridden from TestCompositorHost:
+ virtual void Show() OVERRIDE {
+ ShowWindow(hwnd(), SW_SHOWNORMAL);
+ }
+ virtual ui::Compositor* GetCompositor() OVERRIDE {
+ return compositor_.get();
+ }
+
+ // Overridden from CompositorDelegate:
+ virtual void ScheduleDraw() OVERRIDE {
+ RECT rect;
+ ::GetClientRect(hwnd(), &rect);
+ InvalidateRect(hwnd(), &rect, FALSE);
+ }
+
+ private:
+ BEGIN_MSG_MAP_EX(TestCompositorHostWin)
+ MSG_WM_PAINT(OnPaint)
+ END_MSG_MAP()
+
+ void OnPaint(HDC dc) {
+ compositor_->Draw(false);
+ ValidateRect(hwnd(), NULL);
+ }
+
+ gfx::Size GetSize() {
+ RECT r;
+ GetClientRect(hwnd(), &r);
+ return gfx::Rect(r).size();
+ }
+
+ scoped_ptr<ui::Compositor> compositor_;
+
+ DISALLOW_COPY_AND_ASSIGN(TestCompositorHostWin);
+};
+
+TestCompositorHost* TestCompositorHost::Create(const gfx::Rect& bounds) {
+ return new TestCompositorHostWin(bounds);
+}
+
+} // namespace ui
diff --git a/ui/compositor/test/test_layer_animation_delegate.cc b/ui/compositor/test/test_layer_animation_delegate.cc
new file mode 100644
index 0000000..b4cd481
--- /dev/null
+++ b/ui/compositor/test/test_layer_animation_delegate.cc
@@ -0,0 +1,62 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/compositor/test/test_layer_animation_delegate.h"
+
+namespace ui {
+
+TestLayerAnimationDelegate::TestLayerAnimationDelegate()
+ : opacity_(1.0f),
+ visibility_(true) {
+}
+
+TestLayerAnimationDelegate::TestLayerAnimationDelegate(
+ const LayerAnimationDelegate& other)
+ : bounds_(other.GetBoundsForAnimation()),
+ transform_(other.GetTransformForAnimation()),
+ opacity_(other.GetOpacityForAnimation()),
+ visibility_(other.GetVisibilityForAnimation()) {
+}
+
+TestLayerAnimationDelegate::~TestLayerAnimationDelegate() {
+}
+
+void TestLayerAnimationDelegate::SetBoundsFromAnimation(
+ const gfx::Rect& bounds) {
+ bounds_ = bounds;
+}
+
+void TestLayerAnimationDelegate::SetTransformFromAnimation(
+ const Transform& transform) {
+ transform_ = transform;
+}
+
+void TestLayerAnimationDelegate::SetOpacityFromAnimation(float opacity) {
+ opacity_ = opacity;
+}
+
+void TestLayerAnimationDelegate::SetVisibilityFromAnimation(bool visibility) {
+ visibility_ = visibility;
+}
+
+void TestLayerAnimationDelegate::ScheduleDrawForAnimation() {
+}
+
+const gfx::Rect& TestLayerAnimationDelegate::GetBoundsForAnimation() const {
+ return bounds_;
+}
+
+const Transform& TestLayerAnimationDelegate::GetTransformForAnimation() const {
+ return transform_;
+}
+
+float TestLayerAnimationDelegate::GetOpacityForAnimation() const {
+ return opacity_;
+}
+
+bool TestLayerAnimationDelegate::GetVisibilityForAnimation() const {
+ return visibility_;
+}
+
+} // namespace ui
diff --git a/ui/compositor/test/test_layer_animation_delegate.h b/ui/compositor/test/test_layer_animation_delegate.h
new file mode 100644
index 0000000..4b624b9
--- /dev/null
+++ b/ui/compositor/test/test_layer_animation_delegate.h
@@ -0,0 +1,44 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_GFX_COMPOSITOR_TEST_TEST_LAYER_ANIMATION_DELEGATE_H_
+#define UI_GFX_COMPOSITOR_TEST_TEST_LAYER_ANIMATION_DELEGATE_H_
+#pragma once
+
+#include "base/compiler_specific.h"
+#include "ui/compositor/layer_animation_delegate.h"
+#include "ui/gfx/rect.h"
+#include "ui/gfx/transform.h"
+
+namespace ui {
+
+class TestLayerAnimationDelegate : public LayerAnimationDelegate {
+ public:
+ TestLayerAnimationDelegate();
+ explicit TestLayerAnimationDelegate(const LayerAnimationDelegate& other);
+ virtual ~TestLayerAnimationDelegate();
+
+ // Implementation of LayerAnimationDelegate
+ virtual void SetBoundsFromAnimation(const gfx::Rect& bounds) OVERRIDE;
+ virtual void SetTransformFromAnimation(const Transform& transform) OVERRIDE;
+ virtual void SetOpacityFromAnimation(float opacity) OVERRIDE;
+ virtual void SetVisibilityFromAnimation(bool visibility) OVERRIDE;
+ virtual void ScheduleDrawForAnimation() OVERRIDE;
+ virtual const gfx::Rect& GetBoundsForAnimation() const OVERRIDE;
+ virtual const Transform& GetTransformForAnimation() const OVERRIDE;
+ virtual float GetOpacityForAnimation() const OVERRIDE;
+ virtual bool GetVisibilityForAnimation() const OVERRIDE;
+
+ private:
+ gfx::Rect bounds_;
+ Transform transform_;
+ float opacity_;
+ bool visibility_;
+
+ // Allow copy and assign.
+};
+
+} // namespace ui
+
+#endif // UI_GFX_COMPOSITOR_TEST_TEST_LAYER_ANIMATION_DELEGATE_H_
diff --git a/ui/compositor/test/test_layer_animation_observer.cc b/ui/compositor/test/test_layer_animation_observer.cc
new file mode 100644
index 0000000..abc74ae
--- /dev/null
+++ b/ui/compositor/test/test_layer_animation_observer.cc
@@ -0,0 +1,41 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/compositor/test/test_layer_animation_observer.h"
+
+#include <cstddef>
+
+namespace ui {
+
+TestLayerAnimationObserver::TestLayerAnimationObserver()
+ : last_ended_sequence_(NULL),
+ last_scheduled_sequence_(NULL),
+ last_aborted_sequence_(NULL),
+ requires_notification_when_animator_destroyed_(false) {
+}
+
+TestLayerAnimationObserver::~TestLayerAnimationObserver() {
+}
+
+void TestLayerAnimationObserver::OnLayerAnimationEnded(
+ LayerAnimationSequence* sequence) {
+ last_ended_sequence_ = sequence;
+}
+
+void TestLayerAnimationObserver::OnLayerAnimationAborted(
+ LayerAnimationSequence* sequence) {
+ last_aborted_sequence_ = sequence;
+}
+
+void TestLayerAnimationObserver::OnLayerAnimationScheduled(
+ LayerAnimationSequence* sequence) {
+ last_scheduled_sequence_ = sequence;
+}
+
+bool
+TestLayerAnimationObserver::RequiresNotificationWhenAnimatorDestroyed() const {
+ return requires_notification_when_animator_destroyed_;
+}
+
+} // namespace ui
diff --git a/ui/compositor/test/test_layer_animation_observer.h b/ui/compositor/test/test_layer_animation_observer.h
new file mode 100644
index 0000000..af0a9d8
--- /dev/null
+++ b/ui/compositor/test/test_layer_animation_observer.h
@@ -0,0 +1,61 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_GFX_COMPOSITOR_TEST_TEST_LAYER_ANIMATION_OBSERVER_
+#define UI_GFX_COMPOSITOR_TEST_TEST_LAYER_ANIMATION_OBSERVER_
+#pragma once
+
+#include "base/compiler_specific.h"
+#include "ui/compositor/layer_animation_observer.h"
+
+namespace ui {
+
+class LayerAnimationSequence;
+
+// Listens to animation ended notifications. Remembers the last sequence that
+// it was notified about.
+class TestLayerAnimationObserver : public LayerAnimationObserver {
+ public:
+ TestLayerAnimationObserver();
+ virtual ~TestLayerAnimationObserver();
+
+ virtual void OnLayerAnimationEnded(
+ LayerAnimationSequence* sequence) OVERRIDE;
+
+ virtual void OnLayerAnimationAborted(
+ LayerAnimationSequence* sequence) OVERRIDE;
+
+ virtual void OnLayerAnimationScheduled(
+ LayerAnimationSequence* sequence) OVERRIDE;
+
+ virtual bool RequiresNotificationWhenAnimatorDestroyed() const OVERRIDE;
+
+ const LayerAnimationSequence* last_ended_sequence() const {
+ return last_ended_sequence_;
+ }
+
+ const LayerAnimationSequence* last_scheduled_sequence() const {
+ return last_scheduled_sequence_;
+ }
+
+ const LayerAnimationSequence* last_aborted_sequence() const {
+ return last_aborted_sequence_;
+ }
+
+ void set_requires_notification_when_animator_destroyed(bool value) {
+ requires_notification_when_animator_destroyed_ = value;
+ }
+
+ private:
+ const LayerAnimationSequence* last_ended_sequence_;
+ const LayerAnimationSequence* last_scheduled_sequence_;
+ const LayerAnimationSequence* last_aborted_sequence_;
+ bool requires_notification_when_animator_destroyed_;
+
+ // Copy and assign are allowed.
+};
+
+} // namespace ui
+
+#endif // UI_GFX_COMPOSITOR_TEST_TEST_LAYER_ANIMATION_OBSERVER_
diff --git a/ui/compositor/test/test_suite.cc b/ui/compositor/test/test_suite.cc
new file mode 100644
index 0000000..fd749bb
--- /dev/null
+++ b/ui/compositor/test/test_suite.cc
@@ -0,0 +1,39 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/compositor/test/test_suite.h"
+
+#include "base/message_loop.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h"
+#include "ui/base/ui_base_paths.h"
+#include "ui/compositor/compositor.h"
+#include "ui/compositor/test/compositor_test_support.h"
+#include "ui/gfx/gfx_paths.h"
+#include "ui/gfx/gl/gl_implementation.h"
+
+CompositorTestSuite::CompositorTestSuite(int argc, char** argv)
+ : TestSuite(argc, argv) {}
+
+CompositorTestSuite::~CompositorTestSuite() {}
+
+void CompositorTestSuite::Initialize() {
+#if defined(OS_LINUX)
+ gfx::InitializeGLBindings(gfx::kGLImplementationOSMesaGL);
+#endif
+ base::TestSuite::Initialize();
+
+ gfx::RegisterPathProvider();
+
+ message_loop_.reset(new MessageLoop(MessageLoop::TYPE_UI));
+ ui::CompositorTestSupport::Initialize();
+ ui::Compositor::Initialize(false);
+}
+
+void CompositorTestSuite::Shutdown() {
+ ui::Compositor::Terminate();
+ ui::CompositorTestSupport::Terminate();
+ message_loop_.reset();
+
+ base::TestSuite::Shutdown();
+}
diff --git a/ui/compositor/test/test_suite.h b/ui/compositor/test/test_suite.h
new file mode 100644
index 0000000..6f64fa6
--- /dev/null
+++ b/ui/compositor/test/test_suite.h
@@ -0,0 +1,29 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_GFX_COMPOSITOR_TEST_TEST_SUITE_H_
+#define UI_GFX_COMPOSITOR_TEST_TEST_SUITE_H_
+#pragma once
+
+#include "base/compiler_specific.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/test/test_suite.h"
+
+class MessageLoop;
+
+class CompositorTestSuite : public base::TestSuite {
+ public:
+ CompositorTestSuite(int argc, char** argv);
+ virtual ~CompositorTestSuite();
+
+ protected:
+ // base::TestSuite:
+ virtual void Initialize() OVERRIDE;
+ virtual void Shutdown() OVERRIDE;
+
+ private:
+ scoped_ptr<MessageLoop> message_loop_;
+};
+
+#endif // UI_GFX_COMPOSITOR_TEST_TEST_SUITE_H_
diff --git a/ui/compositor/test/test_utils.cc b/ui/compositor/test/test_utils.cc
new file mode 100644
index 0000000..43f7f02
--- /dev/null
+++ b/ui/compositor/test/test_utils.cc
@@ -0,0 +1,28 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/compositor/test/test_utils.h"
+
+#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/gfx/rect.h"
+#include "ui/gfx/transform.h"
+
+namespace ui {
+
+void CheckApproximatelyEqual(const Transform& lhs, const Transform& rhs) {
+ for (int i = 0; i < 4; ++i) {
+ for (int j = 0; j < 4; ++j) {
+ EXPECT_FLOAT_EQ(lhs.matrix().get(i, j), rhs.matrix().get(i, j));
+ }
+ }
+}
+
+void CheckApproximatelyEqual(const gfx::Rect& lhs, const gfx::Rect& rhs) {
+ EXPECT_FLOAT_EQ(lhs.x(), rhs.x());
+ EXPECT_FLOAT_EQ(lhs.y(), rhs.y());
+ EXPECT_FLOAT_EQ(lhs.width(), rhs.width());
+ EXPECT_FLOAT_EQ(lhs.height(), rhs.height());
+}
+
+} // namespace ui
diff --git a/ui/compositor/test/test_utils.h b/ui/compositor/test/test_utils.h
new file mode 100644
index 0000000..47f91d9
--- /dev/null
+++ b/ui/compositor/test/test_utils.h
@@ -0,0 +1,22 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_GFX_COMPOSITOR_TEST_TEST_UTILS_H_
+#define UI_GFX_COMPOSITOR_TEST_TEST_UTILS_H_
+#pragma once
+
+namespace gfx {
+class Rect;
+}
+
+namespace ui {
+
+class Transform;
+
+void CheckApproximatelyEqual(const Transform& lhs, const Transform& rhs);
+void CheckApproximatelyEqual(const gfx::Rect& lhs, const gfx::Rect& rhs);
+
+} // namespace ui
+
+#endif // UI_GFX_COMPOSITOR_TEST_TEST_UTILS_H_