summaryrefslogtreecommitdiffstats
path: root/cc/test
diff options
context:
space:
mode:
authordanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-04 02:08:12 +0000
committerdanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-04 02:08:12 +0000
commitd993b6009261f95c35a351450d5ebe401d5329b2 (patch)
treebea737921c010b3bb09fc62281e17fc6a711cdc7 /cc/test
parentb408bfaac44edc0e5cdd6fae239b25cbefe704c2 (diff)
downloadchromium_src-d993b6009261f95c35a351450d5ebe401d5329b2.zip
chromium_src-d993b6009261f95c35a351450d5ebe401d5329b2.tar.gz
chromium_src-d993b6009261f95c35a351450d5ebe401d5329b2.tar.bz2
cc: Put context-loss tests in layer_tree_host_unittest_context.cc
These tests cover all of the cases covered by the context loss layout test and more. It also provides full coverage both in single-thread and multi-thread modes. I've moved tests from LayerTreeHostTests as usual, but also tests from LayerTreeHostImplTests, and implemented them using the real commit flow, instantiating layers by making the main thread versions of the layers, etc. This makes for a much more realistic test, and doesn't rely on as much internal compositor knowledge. While digging around, I found that the layersFreeTextures test was not testing anything. Then I also noticed that most of the layers in the test are not actually responsible to free their resources when they disappear. So I made the test do its job, and made the test just check layers that own resources - namely IOSurface and Video layers. Tests: LayerTreeHostContextTestLostContextSucceeds.runSingleThread LayerTreeHostContextTestLostContextSucceeds.runMultiThread LayerTreeHostContextTestLostContextSucceedsWithContent.NoSurface_SingleThread LayerTreeHostContextTestLostContextSucceedsWithContent.NoSurface_MultiThread LayerTreeHostContextTestLostContextSucceedsWithContent.WithSurface_SingleThread LayerTreeHostContextTestLostContextSucceedsWithContent.WithSurface_MultiThread LayerTreeHostContextTestLostContextFails.RepeatLoss100_SingleThread LayerTreeHostContextTestLostContextFails.RepeatLoss100_MultiThread LayerTreeHostContextTestLostContextFails.FailRecreate100_SingleThread LayerTreeHostContextTestLostContextFails.FailRecreate100_MultiThread LayerTreeHostContextTestFinishAllRenderingAfterLoss.runSingleThread LayerTreeHostContextTestFinishAllRenderingAfterLoss.runMultiThread LayerTreeHostContextTestLostContextAndEvictTextures.LoseAfterEvict_SingleThread LayerTreeHostContextTestLostContextAndEvictTextures.LoseAfterEvict_MultiThread LayerTreeHostContextTestLostContextAndEvictTextures.LoseBeforeEvict_SingleThread LayerTreeHostContextTestLostContextAndEvictTextures.LoseBeforeEvict_MultiThread LayerTreeHostContextTestLostContextWhileUpdatingResources.runSingleThread LayerTreeHostContextTestLostContextWhileUpdatingResources.runMultiThread LayerTreeHostContextTestLayersNotified.runSingleThread LayerTreeHostContextTestLayersNotified.runMultiThread LayerTreeHostContextTestDontUseLostResources.runSingleThread LayerTreeHostContextTestDontUseLostResources.runMultiThread Review URL: https://chromiumcodereview.appspot.com/11662003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@175080 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/test')
-rw-r--r--cc/test/fake_content_layer.cc13
-rw-r--r--cc/test/fake_content_layer.h13
-rw-r--r--cc/test/fake_content_layer_impl.cc24
-rw-r--r--cc/test/fake_content_layer_impl.h38
-rw-r--r--cc/test/fake_scrollbar_layer.cc4
-rw-r--r--cc/test/fake_scrollbar_layer.h7
-rw-r--r--cc/test/fake_video_frame.cc63
-rw-r--r--cc/test/fake_video_frame.h39
-rw-r--r--cc/test/fake_video_frame_provider.cc25
-rw-r--r--cc/test/fake_video_frame_provider.h35
-rw-r--r--cc/test/fake_web_graphics_context_3d.cc174
-rw-r--r--cc/test/fake_web_graphics_context_3d.h61
-rw-r--r--cc/test/fake_web_scrollbar_theme_geometry.cc68
-rw-r--r--cc/test/fake_web_scrollbar_theme_geometry.h6
-rw-r--r--cc/test/layer_tree_test_common.h40
-rw-r--r--cc/test/render_pass_test_common.cc12
16 files changed, 505 insertions, 117 deletions
diff --git a/cc/test/fake_content_layer.cc b/cc/test/fake_content_layer.cc
index f217e93..c103b24 100644
--- a/cc/test/fake_content_layer.cc
+++ b/cc/test/fake_content_layer.cc
@@ -4,6 +4,9 @@
#include "cc/test/fake_content_layer.h"
+#include "cc/prioritized_resource.h"
+#include "cc/test/fake_content_layer_impl.h"
+
namespace cc {
FakeContentLayer::FakeContentLayer(ContentLayerClient* client)
@@ -16,6 +19,11 @@ FakeContentLayer::FakeContentLayer(ContentLayerClient* client)
FakeContentLayer::~FakeContentLayer() {}
+scoped_ptr<LayerImpl> FakeContentLayer::createLayerImpl(
+ LayerTreeImpl* tree_impl) {
+ return FakeContentLayerImpl::Create(tree_impl, m_layerId).PassAs<LayerImpl>();
+}
+
void FakeContentLayer::update(
ResourceUpdateQueue& queue,
const OcclusionTracker* occlusion,
@@ -24,4 +32,9 @@ void FakeContentLayer::update(
update_count_++;
}
+bool FakeContentLayer::HaveBackingAt(int i, int j) {
+ const PrioritizedResource* resource = resourceAtForTesting(i, j);
+ return resource && resource->haveBackingTexture();
+}
+
} // namespace cc
diff --git a/cc/test/fake_content_layer.h b/cc/test/fake_content_layer.h
index 7defe6a..94b1266 100644
--- a/cc/test/fake_content_layer.h
+++ b/cc/test/fake_content_layer.h
@@ -11,12 +11,15 @@
namespace cc {
class FakeContentLayer : public ContentLayer {
-public:
+ public:
static scoped_refptr<FakeContentLayer> Create(ContentLayerClient* client) {
return make_scoped_refptr(new FakeContentLayer(client));
}
- int update_count() { return update_count_; }
+ virtual scoped_ptr<LayerImpl> createLayerImpl(LayerTreeImpl* tree_impl)
+ OVERRIDE;
+
+ size_t update_count() const { return update_count_; }
void reset_update_count() { update_count_ = 0; }
virtual void update(
@@ -24,11 +27,13 @@ public:
const OcclusionTracker* occlusion,
RenderingStats& stats) OVERRIDE;
-private:
+ bool HaveBackingAt(int i, int j);
+
+ private:
explicit FakeContentLayer(ContentLayerClient* client);
virtual ~FakeContentLayer();
- int update_count_;
+ size_t update_count_;
};
} // namespace cc
diff --git a/cc/test/fake_content_layer_impl.cc b/cc/test/fake_content_layer_impl.cc
new file mode 100644
index 0000000..9404947
--- /dev/null
+++ b/cc/test/fake_content_layer_impl.cc
@@ -0,0 +1,24 @@
+// Copyright 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 "cc/test/fake_content_layer_impl.h"
+
+namespace cc {
+
+FakeContentLayerImpl::FakeContentLayerImpl(LayerTreeImpl* tree_impl, int id)
+ : TiledLayerImpl(tree_impl, id),
+ lost_output_surface_count_(0) {
+}
+
+FakeContentLayerImpl::~FakeContentLayerImpl() {}
+
+bool FakeContentLayerImpl::HaveResourceForTileAt(int i, int j) {
+ return hasResourceIdForTileAt(i, j);
+}
+
+void FakeContentLayerImpl::didLoseOutputSurface() {
+ ++lost_output_surface_count_;
+}
+
+} // namespace cc
diff --git a/cc/test/fake_content_layer_impl.h b/cc/test/fake_content_layer_impl.h
new file mode 100644
index 0000000..0d797a6
--- /dev/null
+++ b/cc/test/fake_content_layer_impl.h
@@ -0,0 +1,38 @@
+// Copyright 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 CC_TEST_FAKE_CONTENT_LAYER_IMPL_H_
+#define CC_TEST_FAKE_CONTENT_LAYER_IMPL_H_
+
+#include "base/memory/scoped_ptr.h"
+#include "cc/tiled_layer_impl.h"
+
+namespace cc {
+
+class FakeContentLayerImpl : public TiledLayerImpl {
+ public:
+ static scoped_ptr<FakeContentLayerImpl> Create(
+ LayerTreeImpl* tree_impl, int id) {
+ return make_scoped_ptr(new FakeContentLayerImpl(tree_impl, id));
+ }
+ virtual ~FakeContentLayerImpl();
+
+ bool HaveResourceForTileAt(int i, int j);
+
+ size_t lost_output_surface_count() const {
+ return lost_output_surface_count_;
+ }
+ void reset_lost_output_surface_count() { lost_output_surface_count_ = 0; }
+
+ virtual void didLoseOutputSurface() OVERRIDE;
+
+ private:
+ explicit FakeContentLayerImpl(LayerTreeImpl* tree_impl, int id);
+
+ size_t lost_output_surface_count_;
+};
+
+} // namespace cc
+
+#endif // CC_TEST_FAKE_CONTENT_LAYER_IMPL_H_
diff --git a/cc/test/fake_scrollbar_layer.cc b/cc/test/fake_scrollbar_layer.cc
index 7d5d968..d6e5f0a 100644
--- a/cc/test/fake_scrollbar_layer.cc
+++ b/cc/test/fake_scrollbar_layer.cc
@@ -11,12 +11,12 @@
namespace cc {
FakeScrollbarLayer::FakeScrollbarLayer(
- bool paint_during_update, int scrolling_layer_id)
+ bool paint_during_update, bool has_thumb, int scrolling_layer_id)
: ScrollbarLayer(
FakeWebScrollbar::create().PassAs<WebKit::WebScrollbar>(),
FakeScrollbarThemePainter::Create(paint_during_update)
.PassAs<ScrollbarThemePainter>(),
- FakeWebScrollbarThemeGeometry::create()
+ FakeWebScrollbarThemeGeometry::create(has_thumb)
.PassAs<WebKit::WebScrollbarThemeGeometry>(),
scrolling_layer_id),
update_count_(0) {
diff --git a/cc/test/fake_scrollbar_layer.h b/cc/test/fake_scrollbar_layer.h
index 354cf8b..6bc2707 100644
--- a/cc/test/fake_scrollbar_layer.h
+++ b/cc/test/fake_scrollbar_layer.h
@@ -13,9 +13,9 @@ namespace cc {
class FakeScrollbarLayer : public ScrollbarLayer {
public:
static scoped_refptr<FakeScrollbarLayer> Create(
- bool paint_during_update, int scrolling_layer_id) {
+ bool paint_during_update, bool has_thumb, int scrolling_layer_id) {
return make_scoped_refptr(new FakeScrollbarLayer(
- paint_during_update, scrolling_layer_id));
+ paint_during_update, has_thumb, scrolling_layer_id));
}
int update_count() { return update_count_; }
@@ -27,7 +27,8 @@ public:
RenderingStats& stats) OVERRIDE;
private:
- FakeScrollbarLayer(bool paint_during_update, int scrolling_layer_id);
+ FakeScrollbarLayer(
+ bool paint_during_update, bool has_thumb, int scrolling_layer_id);
virtual ~FakeScrollbarLayer();
int update_count_;
diff --git a/cc/test/fake_video_frame.cc b/cc/test/fake_video_frame.cc
new file mode 100644
index 0000000..3efe462
--- /dev/null
+++ b/cc/test/fake_video_frame.cc
@@ -0,0 +1,63 @@
+// Copyright 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 "cc/test/fake_video_frame.h"
+
+namespace cc {
+
+FakeVideoFrame::FakeVideoFrame(const scoped_refptr<media::VideoFrame>& frame)
+ : frame_(frame) {}
+
+FakeVideoFrame::~FakeVideoFrame() {}
+
+WebKit::WebVideoFrame::Format FakeVideoFrame::format() const {
+ return FormatInvalid;
+}
+
+unsigned FakeVideoFrame::width() const {
+ return frame_->natural_size().width();
+}
+
+unsigned FakeVideoFrame::height() const {
+ return frame_->natural_size().height();
+}
+
+unsigned FakeVideoFrame::planes() const {
+ return 0;
+}
+
+int FakeVideoFrame::stride(unsigned plane) const {
+ return 0;
+}
+
+const void* FakeVideoFrame::data(unsigned plane) const {
+ return NULL;
+}
+
+unsigned FakeVideoFrame::textureId() const {
+ return frame_->texture_id();
+}
+
+unsigned FakeVideoFrame::textureTarget() const {
+ return frame_->texture_target();
+}
+
+WebKit::WebRect FakeVideoFrame::visibleRect() const {
+ return frame_->visible_rect();
+}
+
+WebKit::WebSize FakeVideoFrame::textureSize() const {
+ return frame_->coded_size();
+}
+
+// static
+media::VideoFrame* FakeVideoFrame::ToVideoFrame(
+ WebKit::WebVideoFrame* web_video_frame) {
+ if (!web_video_frame)
+ return NULL;
+ FakeVideoFrame* fake_frame = static_cast<FakeVideoFrame*>(web_video_frame);
+ return fake_frame->frame_.get();
+}
+
+} // namespace cc
diff --git a/cc/test/fake_video_frame.h b/cc/test/fake_video_frame.h
new file mode 100644
index 0000000..0631f48
--- /dev/null
+++ b/cc/test/fake_video_frame.h
@@ -0,0 +1,39 @@
+// Copyright 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 CC_TEST_FAKE_VIDEO_FRAME_H_
+#define CC_TEST_FAKE_VIDEO_FRAME_H_
+
+#include "media/base/video_frame.h"
+#include "third_party/WebKit/Source/Platform/chromium/public/WebVideoFrame.h"
+
+namespace cc {
+
+class FakeVideoFrame : public WebKit::WebVideoFrame {
+ public:
+ explicit FakeVideoFrame(const scoped_refptr<media::VideoFrame>& frame);
+ virtual ~FakeVideoFrame();
+
+ // WebKit::WebVideoFrame implementation.
+ virtual Format format() const;
+ virtual unsigned width() const;
+ virtual unsigned height() const;
+ virtual unsigned planes() const;
+ virtual int stride(unsigned plane) const;
+ virtual const void* data(unsigned plane) const;
+ virtual unsigned textureId() const;
+ virtual unsigned textureTarget() const;
+ virtual WebKit::WebRect visibleRect() const;
+ virtual WebKit::WebSize textureSize() const;
+
+ static media::VideoFrame* ToVideoFrame(
+ WebKit::WebVideoFrame* web_video_frame);
+
+ private:
+ scoped_refptr<media::VideoFrame> frame_;
+};
+
+} // namespace cc
+
+#endif // CC_TEST_FAKE_VIDEO_FRAME_H_
diff --git a/cc/test/fake_video_frame_provider.cc b/cc/test/fake_video_frame_provider.cc
new file mode 100644
index 0000000..bf0a3cf
--- /dev/null
+++ b/cc/test/fake_video_frame_provider.cc
@@ -0,0 +1,25 @@
+// Copyright 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 "cc/test/fake_video_frame_provider.h"
+
+namespace cc {
+
+FakeVideoFrameProvider::FakeVideoFrameProvider()
+ : frame_(NULL), client_(NULL) {}
+
+FakeVideoFrameProvider::~FakeVideoFrameProvider() {
+ if (client_)
+ client_->stopUsingProvider();
+}
+
+void FakeVideoFrameProvider::setVideoFrameProviderClient(Client* client) {
+ client_ = client;
+}
+
+WebKit::WebVideoFrame* FakeVideoFrameProvider::getCurrentFrame() {
+ return frame_;
+}
+
+} // namespace cc
diff --git a/cc/test/fake_video_frame_provider.h b/cc/test/fake_video_frame_provider.h
new file mode 100644
index 0000000..f44dee6
--- /dev/null
+++ b/cc/test/fake_video_frame_provider.h
@@ -0,0 +1,35 @@
+// Copyright 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 CC_TEST_FAKE_VIDEO_FRAME_PROVIDER_H_
+#define CC_TEST_FAKE_VIDEO_FRAME_PROVIDER_H_
+
+#include "base/memory/scoped_ptr.h"
+#include "cc/test/fake_video_frame.h"
+#include "third_party/WebKit/Source/Platform/chromium/public/WebVideoFrameProvider.h"
+
+namespace cc {
+
+// Fake video frame provider that always provides the same VideoFrame.
+class FakeVideoFrameProvider: public WebKit::WebVideoFrameProvider {
+ public:
+ FakeVideoFrameProvider();
+ virtual ~FakeVideoFrameProvider();
+
+ virtual void setVideoFrameProviderClient(Client* client) OVERRIDE;
+ virtual WebKit::WebVideoFrame* getCurrentFrame() OVERRIDE;
+ virtual void putCurrentFrame(WebKit::WebVideoFrame*) OVERRIDE {}
+
+ void set_frame(FakeVideoFrame* frame) {
+ frame_ = frame;
+ }
+
+ private:
+ FakeVideoFrame* frame_;
+ Client* client_;
+};
+
+} // namespace cc
+
+#endif // CC_TEST_FAKE_VIDEO_FRAME_PROVIDER_H_
diff --git a/cc/test/fake_web_graphics_context_3d.cc b/cc/test/fake_web_graphics_context_3d.cc
index 5cb39b1..ede316d 100644
--- a/cc/test/fake_web_graphics_context_3d.cc
+++ b/cc/test/fake_web_graphics_context_3d.cc
@@ -5,8 +5,10 @@
#include "cc/test/fake_web_graphics_context_3d.h"
#include <algorithm>
+#include <string>
#include "base/logging.h"
+#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/khronos/GLES2/gl2ext.h"
using WebKit::WGC3Dboolean;
@@ -16,36 +18,69 @@ using WebKit::WebGraphicsContext3D;
namespace cc {
+static const WebGLId kBufferId = 1;
+static const WebGLId kFramebufferId = 2;
+static const WebGLId kProgramId = 3;
+static const WebGLId kRenderbufferId = 4;
+static const WebGLId kShaderId = 5;
+
+static unsigned s_context_id = 1;
+
+const WebGLId FakeWebGraphicsContext3D::kExternalTextureId = 1337;
+
FakeWebGraphicsContext3D::FakeWebGraphicsContext3D()
- : next_texture_id_(1)
- , context_lost_(false)
- , context_lost_callback_(NULL)
-{
+ : context_id_(s_context_id++),
+ next_texture_id_(1),
+ have_extension_io_surface_(false),
+ have_extension_egl_image_(false),
+ times_make_current_succeeds_(-1),
+ times_bind_texture_succeeds_(-1),
+ times_end_query_succeeds_(-1),
+ context_lost_(false),
+ context_lost_callback_(NULL),
+ width_(0),
+ height_(0) {
}
FakeWebGraphicsContext3D::FakeWebGraphicsContext3D(
const WebGraphicsContext3D::Attributes& attributes)
- : next_texture_id_(1)
- , attributes_(attributes)
- , context_lost_(false)
- , context_lost_callback_(NULL)
-{
+ : context_id_(s_context_id++),
+ next_texture_id_(1),
+ attributes_(attributes),
+ have_extension_io_surface_(false),
+ have_extension_egl_image_(false),
+ times_make_current_succeeds_(-1),
+ times_bind_texture_succeeds_(-1),
+ times_end_query_succeeds_(-1),
+ context_lost_(false),
+ context_lost_callback_(NULL),
+ width_(0),
+ height_(0) {
}
-FakeWebGraphicsContext3D::~FakeWebGraphicsContext3D()
-{
+FakeWebGraphicsContext3D::~FakeWebGraphicsContext3D() {
}
bool FakeWebGraphicsContext3D::makeContextCurrent() {
+ if (times_make_current_succeeds_ >= 0) {
+ if (!times_make_current_succeeds_)
+ loseContextCHROMIUM();
+ --times_make_current_succeeds_;
+ }
return !context_lost_;
}
int FakeWebGraphicsContext3D::width() {
- return 0;
+ return width_;
}
int FakeWebGraphicsContext3D::height() {
- return 0;
+ return height_;
+}
+
+void FakeWebGraphicsContext3D::reshape(int width, int height) {
+ width_ = width;
+ height_ = height;
}
bool FakeWebGraphicsContext3D::isGLES2Compliant() {
@@ -173,7 +208,16 @@ WebKit::WebString FakeWebGraphicsContext3D::getShaderSource(
}
WebKit::WebString FakeWebGraphicsContext3D::getString(WGC3Denum name) {
- return WebKit::WebString();
+ std::string string;
+
+ if (name == GL_EXTENSIONS) {
+ if (have_extension_io_surface_)
+ string += "GL_CHROMIUM_iosurface GL_ARB_texture_rectangle ";
+ if (have_extension_egl_image_)
+ string += "GL_OES_EGL_image_external";
+ }
+
+ return WebKit::WebString::fromUTF8(string.c_str());
}
WebKit::WGC3Dint FakeWebGraphicsContext3D::getUniformLocation(
@@ -224,39 +268,101 @@ WGC3Dboolean FakeWebGraphicsContext3D::isTexture(
}
WebGLId FakeWebGraphicsContext3D::createBuffer() {
- return 1;
+ return kBufferId | context_id_ << 16;
+}
+
+void FakeWebGraphicsContext3D::deleteBuffer(WebKit::WebGLId id) {
+ EXPECT_EQ(kBufferId | context_id_ << 16, id);
}
WebGLId FakeWebGraphicsContext3D::createFramebuffer() {
- return 1;
+ return kFramebufferId | context_id_ << 16;
+}
+
+void FakeWebGraphicsContext3D::deleteFramebuffer(WebKit::WebGLId id) {
+ EXPECT_EQ(kFramebufferId | context_id_ << 16, id);
}
WebGLId FakeWebGraphicsContext3D::createProgram() {
- return 1;
+ return kProgramId | context_id_ << 16;
+}
+
+void FakeWebGraphicsContext3D::deleteProgram(WebKit::WebGLId id) {
+ EXPECT_EQ(kProgramId | context_id_ << 16, id);
}
WebGLId FakeWebGraphicsContext3D::createRenderbuffer() {
- return 1;
+ return kRenderbufferId | context_id_ << 16;
+}
+
+void FakeWebGraphicsContext3D::deleteRenderbuffer(WebKit::WebGLId id) {
+ EXPECT_EQ(kRenderbufferId | context_id_ << 16, id);
}
WebGLId FakeWebGraphicsContext3D::createShader(WGC3Denum) {
- return 1;
+ return kShaderId | context_id_ << 16;
+}
+
+void FakeWebGraphicsContext3D::deleteShader(WebKit::WebGLId id) {
+ EXPECT_EQ(kShaderId | context_id_ << 16, id);
}
WebGLId FakeWebGraphicsContext3D::createTexture() {
- WebGLId texture_id = next_texture_id_++;
+ WebGLId texture_id = NextTextureId();
+ DCHECK_NE(texture_id, kExternalTextureId);
textures_.push_back(texture_id);
return texture_id;
}
void FakeWebGraphicsContext3D::deleteTexture(WebGLId texture_id) {
+ DCHECK(std::find(textures_.begin(), textures_.end(), texture_id) !=
+ textures_.end());
textures_.erase(std::find(textures_.begin(), textures_.end(), texture_id));
}
+void FakeWebGraphicsContext3D::attachShader(WebGLId program, WebGLId shader) {
+ EXPECT_EQ(kProgramId | context_id_ << 16, program);
+ EXPECT_EQ(kShaderId | context_id_ << 16, shader);
+}
+
+void FakeWebGraphicsContext3D::useProgram(WebGLId program) {
+ if (!program)
+ return;
+ EXPECT_EQ(kProgramId | context_id_ << 16, program);
+}
+
+void FakeWebGraphicsContext3D::bindBuffer(WGC3Denum target, WebGLId buffer) {
+ if (!buffer)
+ return;
+ EXPECT_EQ(kBufferId | context_id_ << 16, buffer);
+}
+
+void FakeWebGraphicsContext3D::bindFramebuffer(
+ WGC3Denum target, WebGLId framebuffer) {
+ if (!framebuffer)
+ return;
+ EXPECT_EQ(kFramebufferId | context_id_ << 16, framebuffer);
+}
+
+void FakeWebGraphicsContext3D::bindRenderbuffer(
+ WGC3Denum target, WebGLId renderbuffer) {
+ if (!renderbuffer)
+ return;
+ EXPECT_EQ(kRenderbufferId | context_id_ << 16, renderbuffer);
+}
+
void FakeWebGraphicsContext3D::bindTexture(
WGC3Denum target, WebGLId texture_id) {
+ if (times_bind_texture_succeeds_ >= 0) {
+ if (!times_bind_texture_succeeds_)
+ loseContextCHROMIUM();
+ --times_bind_texture_succeeds_;
+ }
+
if (!texture_id)
return;
+ if (texture_id == kExternalTextureId)
+ return;
DCHECK(std::find(textures_.begin(), textures_.end(), texture_id) !=
textures_.end());
used_textures_.insert(texture_id);
@@ -270,15 +376,41 @@ WGC3Dboolean FakeWebGraphicsContext3D::isQueryEXT(WebGLId query) {
return true;
}
-void FakeWebGraphicsContext3D::SetContextLostCallback(
+void FakeWebGraphicsContext3D::endQueryEXT(WebKit::WGC3Denum target) {
+ if (times_end_query_succeeds_ >= 0) {
+ if (!times_end_query_succeeds_)
+ loseContextCHROMIUM();
+ --times_end_query_succeeds_;
+ }
+}
+
+void FakeWebGraphicsContext3D::getQueryObjectuivEXT(
+ WebKit::WebGLId query,
+ WebKit::WGC3Denum pname,
+ WebKit::WGC3Duint* params) {
+ // If the context is lost, behave as if result is available.
+ if (pname == GL_QUERY_RESULT_AVAILABLE_EXT)
+ *params = 1;
+}
+
+void FakeWebGraphicsContext3D::setContextLostCallback(
WebGraphicsContextLostCallback* callback) {
context_lost_callback_ = callback;
}
void FakeWebGraphicsContext3D::loseContextCHROMIUM() {
+ if (context_lost_)
+ return;
context_lost_ = true;
if (context_lost_callback_)
context_lost_callback_->onContextLost();
}
+WebKit::WebGLId FakeWebGraphicsContext3D::NextTextureId() {
+ WebGLId texture_id = next_texture_id_++;
+ DCHECK(texture_id < (1 << 16));
+ texture_id |= context_id_ << 16;
+ return texture_id;
+}
+
} // namespace cc
diff --git a/cc/test/fake_web_graphics_context_3d.h b/cc/test/fake_web_graphics_context_3d.h
index f940299..09ec68f 100644
--- a/cc/test/fake_web_graphics_context_3d.h
+++ b/cc/test/fake_web_graphics_context_3d.h
@@ -33,7 +33,7 @@ class FakeWebGraphicsContext3D : public WebKit::WebGraphicsContext3D {
virtual int width();
virtual int height();
- virtual void reshape(int width, int height) {}
+ virtual void reshape(int width, int height);
virtual bool isGLES2Compliant();
@@ -103,16 +103,16 @@ class FakeWebGraphicsContext3D : public WebKit::WebGraphicsContext3D {
WebKit::WGC3Dsizei height) {}
virtual void activeTexture(WebKit::WGC3Denum texture) {}
- virtual void attachShader(WebKit::WebGLId program, WebKit::WebGLId shader) {}
+ virtual void attachShader(WebKit::WebGLId program, WebKit::WebGLId shader);
virtual void bindAttribLocation(
WebKit::WebGLId program,
WebKit::WGC3Duint index,
const WebKit::WGC3Dchar* name) {}
- virtual void bindBuffer(WebKit::WGC3Denum target, WebKit::WebGLId buffer) {}
+ virtual void bindBuffer(WebKit::WGC3Denum target, WebKit::WebGLId buffer);
virtual void bindFramebuffer(
- WebKit::WGC3Denum target, WebKit::WebGLId framebuffer) {}
+ WebKit::WGC3Denum target, WebKit::WebGLId framebuffer);
virtual void bindRenderbuffer(
- WebKit::WGC3Denum target, WebKit::WebGLId renderbuffer) {}
+ WebKit::WGC3Denum target, WebKit::WebGLId renderbuffer);
virtual void bindTexture(
WebKit::WGC3Denum target,
WebKit::WebGLId texture_id);
@@ -504,7 +504,7 @@ class FakeWebGraphicsContext3D : public WebKit::WebGraphicsContext3D {
WebKit::WGC3Dboolean transpose,
const WebKit::WGC3Dfloat* value) {}
- virtual void useProgram(WebKit::WebGLId program) {}
+ virtual void useProgram(WebKit::WebGLId program);
virtual void validateProgram(WebKit::WebGLId program) {}
virtual void vertexAttrib1f(WebKit::WGC3Duint index, WebKit::WGC3Dfloat x) {}
@@ -556,11 +556,11 @@ class FakeWebGraphicsContext3D : public WebKit::WebGraphicsContext3D {
virtual WebKit::WebGLId createShader(WebKit::WGC3Denum);
virtual WebKit::WebGLId createTexture();
- virtual void deleteBuffer(WebKit::WebGLId) {}
- virtual void deleteFramebuffer(WebKit::WebGLId) {}
- virtual void deleteProgram(WebKit::WebGLId) {}
- virtual void deleteRenderbuffer(WebKit::WebGLId) {}
- virtual void deleteShader(WebKit::WebGLId) {}
+ virtual void deleteBuffer(WebKit::WebGLId id);
+ virtual void deleteFramebuffer(WebKit::WebGLId id);
+ virtual void deleteProgram(WebKit::WebGLId id);
+ virtual void deleteRenderbuffer(WebKit::WebGLId id);
+ virtual void deleteShader(WebKit::WebGLId id);
virtual void deleteTexture(WebKit::WebGLId texture_id);
virtual void texStorage2DEXT(
@@ -576,21 +576,32 @@ class FakeWebGraphicsContext3D : public WebKit::WebGraphicsContext3D {
virtual void beginQueryEXT(
WebKit::WGC3Denum target,
WebKit::WebGLId query) {}
- virtual void endQueryEXT(WebKit::WGC3Denum target) {}
+ virtual void endQueryEXT(WebKit::WGC3Denum target);
virtual void getQueryivEXT(
WebKit::WGC3Denum target,
WebKit::WGC3Denum pname,
WebKit::WGC3Dint* params) {}
virtual void getQueryObjectuivEXT(
- WebKit::WebGLId,
- WebKit::WGC3Denum,
- WebKit::WGC3Duint*) {}
+ WebKit::WebGLId query,
+ WebKit::WGC3Denum pname,
+ WebKit::WGC3Duint* params);
- virtual void SetContextLostCallback(
+ virtual void setContextLostCallback(
WebGraphicsContextLostCallback* callback);
virtual void loseContextCHROMIUM();
+ // When set, MakeCurrent() will fail after this many times.
+ void set_times_make_current_succeeds(int times) {
+ times_make_current_succeeds_ = times;
+ }
+ void set_times_bind_texture_succeeds(int times) {
+ times_bind_texture_succeeds_ = times;
+ }
+ void set_times_end_query_succeeds(int times) {
+ times_end_query_succeeds_ = times;
+ }
+
size_t NumTextures() const { return textures_.size(); }
WebKit::WebGLId TextureAt(int i) const { return textures_[i]; }
@@ -600,17 +611,35 @@ class FakeWebGraphicsContext3D : public WebKit::WebGraphicsContext3D {
}
void ResetUsedTextures() { used_textures_.clear(); }
+ void set_have_extension_io_surface(bool have) {
+ have_extension_io_surface_ = have;
+ }
+ void set_have_extension_egl_image(bool have) {
+ have_extension_egl_image_ = have;
+ }
+
+ static const WebKit::WebGLId kExternalTextureId;
+ virtual WebKit::WebGLId NextTextureId();
+
protected:
FakeWebGraphicsContext3D();
FakeWebGraphicsContext3D(
const WebKit::WebGraphicsContext3D::Attributes& attributes);
+ unsigned context_id_;
unsigned next_texture_id_;
Attributes attributes_;
+ bool have_extension_io_surface_;
+ bool have_extension_egl_image_;
+ int times_make_current_succeeds_;
+ int times_bind_texture_succeeds_;
+ int times_end_query_succeeds_;
bool context_lost_;
WebGraphicsContextLostCallback* context_lost_callback_;
std::vector<WebKit::WebGLId> textures_;
base::hash_set<WebKit::WebGLId> used_textures_;
+ int width_;
+ int height_;
};
} // namespace cc
diff --git a/cc/test/fake_web_scrollbar_theme_geometry.cc b/cc/test/fake_web_scrollbar_theme_geometry.cc
index 7ae7f7a..8a0f378 100644
--- a/cc/test/fake_web_scrollbar_theme_geometry.cc
+++ b/cc/test/fake_web_scrollbar_theme_geometry.cc
@@ -4,19 +4,25 @@
#include "cc/test/fake_web_scrollbar_theme_geometry.h"
+using WebKit::WebRect;
+
namespace cc {
WebKit::WebScrollbarThemeGeometry*
FakeWebScrollbarThemeGeometry::clone() const {
- return new FakeWebScrollbarThemeGeometry();
+ return new FakeWebScrollbarThemeGeometry(m_hasThumb);
}
int FakeWebScrollbarThemeGeometry::thumbPosition(WebKit::WebScrollbar*) {
- return 0;
+ if (!m_hasThumb)
+ return 0;
+ return 5;
}
int FakeWebScrollbarThemeGeometry::thumbLength(WebKit::WebScrollbar*) {
- return 0;
+ if (!m_hasThumb)
+ return 0;
+ return 2;
}
int FakeWebScrollbarThemeGeometry::trackPosition(WebKit::WebScrollbar*) {
@@ -24,7 +30,7 @@ int FakeWebScrollbarThemeGeometry::trackPosition(WebKit::WebScrollbar*) {
}
int FakeWebScrollbarThemeGeometry::trackLength(WebKit::WebScrollbar*) {
- return 0;
+ return 10;
}
bool FakeWebScrollbarThemeGeometry::hasButtons(WebKit::WebScrollbar*) {
@@ -32,15 +38,17 @@ bool FakeWebScrollbarThemeGeometry::hasButtons(WebKit::WebScrollbar*) {
}
bool FakeWebScrollbarThemeGeometry::hasThumb(WebKit::WebScrollbar*) {
- return false;
+ return m_hasThumb;
}
-WebKit::WebRect FakeWebScrollbarThemeGeometry::trackRect(WebKit::WebScrollbar*) {
- return WebKit::WebRect();
+WebRect FakeWebScrollbarThemeGeometry::trackRect(WebKit::WebScrollbar*) {
+ return WebRect(0, 0, 10, 10);
}
-WebKit::WebRect FakeWebScrollbarThemeGeometry::thumbRect(WebKit::WebScrollbar*) {
- return WebKit::WebRect();
+WebRect FakeWebScrollbarThemeGeometry::thumbRect(WebKit::WebScrollbar*) {
+ if (!m_hasThumb)
+ return WebRect(0, 0, 0, 0);
+ return WebRect(0, 5, 5, 2);
}
int FakeWebScrollbarThemeGeometry::minimumThumbLength(WebKit::WebScrollbar*) {
@@ -51,41 +59,47 @@ int FakeWebScrollbarThemeGeometry::scrollbarThickness(WebKit::WebScrollbar*) {
return 0;
}
-WebKit::WebRect FakeWebScrollbarThemeGeometry::backButtonStartRect(
+WebRect FakeWebScrollbarThemeGeometry::backButtonStartRect(
WebKit::WebScrollbar*) {
- return WebKit::WebRect();
+ return WebRect();
}
-WebKit::WebRect FakeWebScrollbarThemeGeometry::backButtonEndRect(
+WebRect FakeWebScrollbarThemeGeometry::backButtonEndRect(
WebKit::WebScrollbar*) {
- return WebKit::WebRect();
+ return WebRect();
}
-WebKit::WebRect FakeWebScrollbarThemeGeometry::forwardButtonStartRect(
+WebRect FakeWebScrollbarThemeGeometry::forwardButtonStartRect(
WebKit::WebScrollbar*) {
- return WebKit::WebRect();
+ return WebRect();
}
-WebKit::WebRect FakeWebScrollbarThemeGeometry::forwardButtonEndRect(
+WebRect FakeWebScrollbarThemeGeometry::forwardButtonEndRect(
WebKit::WebScrollbar*) {
- return WebKit::WebRect();
+ return WebRect();
}
-WebKit::WebRect FakeWebScrollbarThemeGeometry::constrainTrackRectToTrackPieces(
+WebRect FakeWebScrollbarThemeGeometry::constrainTrackRectToTrackPieces(
WebKit::WebScrollbar*,
- const WebKit::WebRect&) {
- return WebKit::WebRect();
+ const WebRect&) {
+ return WebRect();
}
void FakeWebScrollbarThemeGeometry::splitTrack(
WebKit::WebScrollbar*,
- const WebKit::WebRect& track,
- WebKit::WebRect& startTrack,
- WebKit::WebRect& thumb,
- WebKit::WebRect& endTrack) {
- startTrack = WebKit::WebRect();
- thumb = WebKit::WebRect();
- endTrack = WebKit::WebRect();
+ const WebRect& track,
+ WebRect& startTrack,
+ WebRect& thumb,
+ WebRect& endTrack) {
+ if (!m_hasThumb) {
+ thumb = WebRect(0, 0, 0, 0);
+ startTrack = WebRect(0, 0, 10, 10);
+ endTrack = WebRect(0, 10, 10, 0);
+ } else {
+ thumb = WebRect(0, 5, 5, 2);
+ startTrack = WebRect(0, 5, 0, 5);
+ endTrack = WebRect(0, 0, 0, 5);
+ }
}
} // namespace cc
diff --git a/cc/test/fake_web_scrollbar_theme_geometry.h b/cc/test/fake_web_scrollbar_theme_geometry.h
index 45bd1b7..6c3d38c 100644
--- a/cc/test/fake_web_scrollbar_theme_geometry.h
+++ b/cc/test/fake_web_scrollbar_theme_geometry.h
@@ -12,7 +12,7 @@ namespace cc {
class FakeWebScrollbarThemeGeometry : public WebKit::WebScrollbarThemeGeometry {
public:
- static scoped_ptr<WebKit::WebScrollbarThemeGeometry> create() { return scoped_ptr<WebKit::WebScrollbarThemeGeometry>(new FakeWebScrollbarThemeGeometry()); }
+ static scoped_ptr<WebKit::WebScrollbarThemeGeometry> create(bool hasThumb) { return scoped_ptr<WebKit::WebScrollbarThemeGeometry>(new FakeWebScrollbarThemeGeometry(hasThumb)); }
virtual WebKit::WebScrollbarThemeGeometry* clone() const OVERRIDE;
@@ -32,6 +32,10 @@ public:
virtual WebKit::WebRect forwardButtonEndRect(WebKit::WebScrollbar*) OVERRIDE;
virtual WebKit::WebRect constrainTrackRectToTrackPieces(WebKit::WebScrollbar*, const WebKit::WebRect&) OVERRIDE;
virtual void splitTrack(WebKit::WebScrollbar*, const WebKit::WebRect& track, WebKit::WebRect& startTrack, WebKit::WebRect& thumb, WebKit::WebRect& endTrack) OVERRIDE;
+
+protected:
+ FakeWebScrollbarThemeGeometry(bool hasThumb) : m_hasThumb(hasThumb) { }
+ bool m_hasThumb;
};
} // namespace cc
diff --git a/cc/test/layer_tree_test_common.h b/cc/test/layer_tree_test_common.h
index 05e37fe..3b0cfd6 100644
--- a/cc/test/layer_tree_test_common.h
+++ b/cc/test/layer_tree_test_common.h
@@ -176,44 +176,4 @@ private:
SINGLE_THREAD_TEST_F(TEST_FIXTURE_NAME) \
MULTI_THREAD_TEST_F(TEST_FIXTURE_NAME)
-#define MULTI_THREAD_TEST_P1(TEST_FIXTURE_NAME, P1_NAME, P1) \
- class TEST_FIXTURE_NAME##_##P1_NAME : public TEST_FIXTURE_NAME { \
- public: \
- TEST_FIXTURE_NAME##_##P1_NAME() \
- : TEST_FIXTURE_NAME(P1) {} \
- }; \
- MULTI_THREAD_TEST_F(TEST_FIXTURE_NAME##_##P1)
-
-#define SINGLE_THREAD_TEST_P1(TEST_FIXTURE_NAME, P1_NAME, P1) \
- class TEST_FIXTURE_NAME##_##P1_NAME : public TEST_FIXTURE_NAME { \
- public: \
- TEST_FIXTURE_NAME##_##P1_NAME() \
- : TEST_FIXTURE_NAME(P1) {} \
- }; \
- SINGLE_THREAD_TEST_F(TEST_FIXTURE_NAME##_##P1_NAME)
-
-#define SINGLE_AND_MULTI_THREAD_TEST_P1(TEST_FIXTURE_NAME, P1_NAME, P1) \
- SINGLE_THREAD_TEST_P1(TEST_FIXTURE_NAME, P1) \
- MULTI_THREAD_TEST_P1(TEST_FIXTURE_NAME, P1)
-
-#define MULTI_THREAD_TEST_P2(TEST_FIXTURE_NAME, P1_NAME, P1, P2_NAME, P2) \
- class TEST_FIXTURE_NAME##_##P1_NAME##_##P2_NAME : public TEST_FIXTURE_NAME { \
- public: \
- TEST_FIXTURE_NAME##_##P1_NAME##_##P2_NAME() \
- : TEST_FIXTURE_NAME(P1, P2) {} \
- }; \
- MULTI_THREAD_TEST_F(TEST_FIXTURE_NAME##_##P1_NAME##_##P2_NAME)
-
-#define SINGLE_THREAD_TEST_P2(TEST_FIXTURE_NAME, P1_NAME, P1, P2_NAME, P2) \
- class TEST_FIXTURE_NAME##_##P1_NAME##_##P2_NAME : public TEST_FIXTURE_NAME { \
- public: \
- TEST_FIXTURE_NAME##_##P1_NAME##_##P2_NAME() \
- : TEST_FIXTURE_NAME(P1, P2) {} \
- }; \
- SINGLE_THREAD_TEST_F(TEST_FIXTURE_NAME##_##P1_NAME##_##P2_NAME)
-
-#define SINGLE_AND_MULTI_THREAD_TEST_P2(TEST_FIXTURE_NAME, P1_NAME, P1, P2_NAME, P2) \
- SINGLE_THREAD_TEST_P1(TEST_FIXTURE_NAME, P1, P2) \
- MULTI_THREAD_TEST_P1(TEST_FIXTURE_NAME, P1, P2)
-
#endif // CC_TEST_LAYER_TREE_TEST_COMMON_H_
diff --git a/cc/test/render_pass_test_common.cc b/cc/test/render_pass_test_common.cc
index 5f901f2..b66ca4f 100644
--- a/cc/test/render_pass_test_common.cc
+++ b/cc/test/render_pass_test_common.cc
@@ -29,6 +29,9 @@ void TestRenderPass::AppendOneOfEveryQuadType(
gfx::Size(20, 12),
resourceProvider->bestTextureFormat(),
ResourceProvider::TextureUsageAny);
+ unsigned texture_id = ResourceProvider::ScopedReadLockGL(
+ resourceProvider, texture_resource).textureId();
+
scoped_ptr<cc::SharedQuadState> shared_state = cc::SharedQuadState::Create();
shared_state->SetAll(gfx::Transform(),
rect,
@@ -58,7 +61,7 @@ void TestRenderPass::AppendOneOfEveryQuadType(
rect,
opaque_rect,
gfx::Size(50, 50),
- 1,
+ texture_id,
cc::IOSurfaceDrawQuad::FLIPPED);
AppendQuad(io_surface_quad.PassAs<DrawQuad>());
@@ -88,7 +91,7 @@ void TestRenderPass::AppendOneOfEveryQuadType(
stream_video_quad->SetNew(shared_state.get(),
rect,
opaque_rect,
- 1,
+ texture_id,
gfx::Transform());
AppendQuad(stream_video_quad.PassAs<DrawQuad>());
@@ -156,7 +159,10 @@ void TestRenderPass::AppendOneOfEveryQuadType(
cc::VideoLayerImpl::FramePlane planes[3];
for (int i = 0; i < 3; ++i) {
planes[i].resourceId =
- resourceProvider->createResourceFromExternalTexture(1);
+ resourceProvider->createResource(
+ gfx::Size(20, 12),
+ resourceProvider->bestTextureFormat(),
+ ResourceProvider::TextureUsageAny);
planes[i].size = gfx::Size(100, 100);
planes[i].format = GL_LUMINANCE;
}