summaryrefslogtreecommitdiffstats
path: root/cc/test
diff options
context:
space:
mode:
Diffstat (limited to 'cc/test')
-rw-r--r--cc/test/fake_layer_tree_host_impl_client.h3
-rw-r--r--cc/test/fake_output_surface.cc26
-rw-r--r--cc/test/fake_output_surface.h4
-rw-r--r--cc/test/layer_tree_test.cc8
-rw-r--r--cc/test/layer_tree_test.h2
-rw-r--r--cc/test/scheduler_test_common.cc10
-rw-r--r--cc/test/scheduler_test_common.h30
7 files changed, 32 insertions, 51 deletions
diff --git a/cc/test/fake_layer_tree_host_impl_client.h b/cc/test/fake_layer_tree_host_impl_client.h
index dad4014..58816cc 100644
--- a/cc/test/fake_layer_tree_host_impl_client.h
+++ b/cc/test/fake_layer_tree_host_impl_client.h
@@ -17,9 +17,6 @@ class FakeLayerTreeHostImplClient : public LayerTreeHostImplClient {
scoped_refptr<ContextProvider> offscreen_context_provider) OVERRIDE {}
virtual void DidLoseOutputSurfaceOnImplThread() OVERRIDE {}
virtual void OnSwapBuffersCompleteOnImplThread() OVERRIDE {}
- virtual void OnVSyncParametersChanged(
- base::TimeTicks,
- base::TimeDelta) OVERRIDE {}
virtual void BeginFrameOnImplThread(base::TimeTicks frame_time)
OVERRIDE {}
virtual void OnCanDrawStateChanged(bool can_draw) OVERRIDE {}
diff --git a/cc/test/fake_output_surface.cc b/cc/test/fake_output_surface.cc
index c3f3e1a..9ceadda 100644
--- a/cc/test/fake_output_surface.cc
+++ b/cc/test/fake_output_surface.cc
@@ -8,6 +8,7 @@
#include "base/message_loop.h"
#include "cc/output/compositor_frame_ack.h"
#include "cc/output/output_surface_client.h"
+#include "testing/gtest/include/gtest/gtest.h"
namespace cc {
@@ -17,7 +18,8 @@ FakeOutputSurface::FakeOutputSurface(
: OutputSurface(context3d.Pass()),
num_sent_frames_(0),
needs_begin_frame_(false),
- forced_draw_to_software_device_(false) {
+ forced_draw_to_software_device_(false),
+ fake_weak_ptr_factory_(this) {
if (delegated_rendering) {
capabilities_.delegated_rendering = true;
capabilities_.max_frames_pending = 1;
@@ -28,7 +30,8 @@ FakeOutputSurface::FakeOutputSurface(
scoped_ptr<SoftwareOutputDevice> software_device, bool delegated_rendering)
: OutputSurface(software_device.Pass()),
num_sent_frames_(0),
- forced_draw_to_software_device_(false) {
+ forced_draw_to_software_device_(false),
+ fake_weak_ptr_factory_(this) {
if (delegated_rendering) {
capabilities_.delegated_rendering = true;
capabilities_.max_frames_pending = 1;
@@ -41,7 +44,8 @@ FakeOutputSurface::FakeOutputSurface(
bool delegated_rendering)
: OutputSurface(context3d.Pass(), software_device.Pass()),
num_sent_frames_(0),
- forced_draw_to_software_device_(false) {
+ forced_draw_to_software_device_(false),
+ fake_weak_ptr_factory_(this) {
if (delegated_rendering) {
capabilities_.delegated_rendering = true;
capabilities_.max_frames_pending = 1;
@@ -56,6 +60,7 @@ void FakeOutputSurface::SwapBuffers(CompositorFrame* frame) {
frame->AssignTo(&last_sent_frame_);
++num_sent_frames_;
PostSwapBuffersComplete();
+ DidSwapBuffers();
} else {
OutputSurface::SwapBuffers(frame);
frame->AssignTo(&last_sent_frame_);
@@ -65,12 +70,23 @@ void FakeOutputSurface::SwapBuffers(CompositorFrame* frame) {
void FakeOutputSurface::SetNeedsBeginFrame(bool enable) {
needs_begin_frame_ = enable;
+ OutputSurface::SetNeedsBeginFrame(enable);
+
+ // If there is not BeginFrame emulation from the FrameRateController,
+ // then we just post a BeginFrame to emulate it as part of the test.
+ if (enable && !frame_rate_controller_) {
+ base::MessageLoop::current()->PostDelayedTask(
+ FROM_HERE, base::Bind(&FakeOutputSurface::OnBeginFrame,
+ fake_weak_ptr_factory_.GetWeakPtr()),
+ base::TimeDelta::FromMilliseconds(16));
+ }
}
-void FakeOutputSurface::BeginFrame(base::TimeTicks frame_time) {
- client_->BeginFrame(frame_time);
+void FakeOutputSurface::OnBeginFrame() {
+ OutputSurface::BeginFrame(base::TimeTicks::Now());
}
+
bool FakeOutputSurface::ForcedDrawToSoftwareDevice() const {
return forced_draw_to_software_device_;
}
diff --git a/cc/test/fake_output_surface.h b/cc/test/fake_output_surface.h
index d54ffd3..7bc1a4f 100644
--- a/cc/test/fake_output_surface.h
+++ b/cc/test/fake_output_surface.h
@@ -74,7 +74,6 @@ class FakeOutputSurface : public OutputSurface {
bool needs_begin_frame() const {
return needs_begin_frame_;
}
- void BeginFrame(base::TimeTicks frame_time);
void set_forced_draw_to_software_device(bool forced) {
forced_draw_to_software_device_ = forced;
@@ -95,10 +94,13 @@ class FakeOutputSurface : public OutputSurface {
scoped_ptr<SoftwareOutputDevice> software_device,
bool delegated_rendering);
+ void OnBeginFrame();
+
CompositorFrame last_sent_frame_;
size_t num_sent_frames_;
bool needs_begin_frame_;
bool forced_draw_to_software_device_;
+ base::WeakPtrFactory<FakeOutputSurface> fake_weak_ptr_factory_;
};
static inline scoped_ptr<cc::OutputSurface> CreateFakeOutputSurface() {
diff --git a/cc/test/layer_tree_test.cc b/cc/test/layer_tree_test.cc
index 0bb17f346..9f046d9e 100644
--- a/cc/test/layer_tree_test.cc
+++ b/cc/test/layer_tree_test.cc
@@ -590,9 +590,13 @@ void LayerTreeTest::RunTest(bool threaded,
}
scoped_ptr<OutputSurface> LayerTreeTest::CreateOutputSurface() {
+ scoped_ptr<FakeOutputSurface> output_surface;
if (delegating_renderer_)
- return FakeOutputSurface::CreateDelegating3d().PassAs<OutputSurface>();
- return FakeOutputSurface::Create3d().PassAs<OutputSurface>();
+ output_surface = FakeOutputSurface::CreateDelegating3d();
+ else
+ output_surface = FakeOutputSurface::Create3d();
+ output_surface_ = output_surface.get();
+ return output_surface.PassAs<OutputSurface>();
}
scoped_refptr<cc::ContextProvider> LayerTreeTest::
diff --git a/cc/test/layer_tree_test.h b/cc/test/layer_tree_test.h
index 856caaa..2d67a44 100644
--- a/cc/test/layer_tree_test.h
+++ b/cc/test/layer_tree_test.h
@@ -24,6 +24,7 @@ class LayerImpl;
class LayerTreeHost;
class LayerTreeHostClient;
class LayerTreeHostImpl;
+class FakeOutputSurface;
// Used by test stubs to notify the test when something interesting happens.
class TestHooks : public WebKit::WebAnimationDelegate {
@@ -160,6 +161,7 @@ class LayerTreeTest : public testing::Test, public TestHooks {
LayerTreeSettings settings_;
scoped_ptr<LayerTreeHostClientForTesting> client_;
scoped_ptr<LayerTreeHost> layer_tree_host_;
+ FakeOutputSurface* output_surface_;
bool beginning_;
bool end_when_begin_returns_;
diff --git a/cc/test/scheduler_test_common.cc b/cc/test/scheduler_test_common.cc
index c1aa200..8ccf47e 100644
--- a/cc/test/scheduler_test_common.cc
+++ b/cc/test/scheduler_test_common.cc
@@ -35,16 +35,6 @@ void FakeThread::PostDelayedTask(base::Closure cb, base::TimeDelta delay) {
bool FakeThread::BelongsToCurrentThread() const { return true; }
-void FakeTimeSource::SetClient(TimeSourceClient* client) { client_ = client; }
-
-void FakeTimeSource::SetActive(bool b) { active_ = b; }
-
-bool FakeTimeSource::Active() const { return active_; }
-
-base::TimeTicks FakeTimeSource::LastTickTime() { return base::TimeTicks(); }
-
-base::TimeTicks FakeTimeSource::NextTickTime() { return base::TimeTicks(); }
-
base::TimeTicks FakeDelayBasedTimeSource::Now() const { return now_; }
} // namespace cc
diff --git a/cc/test/scheduler_test_common.h b/cc/test/scheduler_test_common.h
index b3b2c2d..8834e62 100644
--- a/cc/test/scheduler_test_common.h
+++ b/cc/test/scheduler_test_common.h
@@ -62,36 +62,6 @@ class FakeThread : public cc::Thread {
bool run_pending_task_on_overwrite_;
};
-class FakeTimeSource : public cc::TimeSource {
- public:
- FakeTimeSource() : active_(false), client_(0) {}
-
- virtual void SetClient(cc::TimeSourceClient* client) OVERRIDE;
- virtual void SetActive(bool b) OVERRIDE;
- virtual bool Active() const OVERRIDE;
- virtual void SetTimebaseAndInterval(base::TimeTicks timebase,
- base::TimeDelta interval) OVERRIDE {}
- virtual base::TimeTicks LastTickTime() OVERRIDE;
- virtual base::TimeTicks NextTickTime() OVERRIDE;
-
- void Tick() {
- ASSERT_TRUE(active_);
- if (client_)
- client_->OnTimerTick();
- }
-
- void SetNextTickTime(base::TimeTicks next_tick_time) {
- next_tick_time_ = next_tick_time;
- }
-
- protected:
- virtual ~FakeTimeSource() {}
-
- bool active_;
- base::TimeTicks next_tick_time_;
- cc::TimeSourceClient* client_;
-};
-
class FakeDelayBasedTimeSource : public cc::DelayBasedTimeSource {
public:
static scoped_refptr<FakeDelayBasedTimeSource> Create(