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

Unified Diff: cc/trees/layer_tree_host_unittest_context.cc

Issue 18191020: UI Resource Manager (Closed) Base URL: https://src.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 5 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
Index: cc/trees/layer_tree_host_unittest_context.cc
===================================================================
--- cc/trees/layer_tree_host_unittest_context.cc (revision 210393)
+++ cc/trees/layer_tree_host_unittest_context.cc (working copy)
@@ -29,6 +29,7 @@
#include "cc/test/fake_video_frame_provider.h"
#include "cc/test/layer_tree_test.h"
#include "cc/test/render_pass_test_common.h"
+#include "cc/test/test_ui_resource_client.h"
#include "cc/test/test_web_graphics_context_3d.h"
#include "cc/trees/layer_tree_host_impl.h"
#include "cc/trees/layer_tree_impl.h"
@@ -1501,21 +1502,17 @@
LayerTreeHostContextTest::CommitCompleteOnThread(impl);
++commits_;
- size_t upload_count = scrollbar_layer_->last_update_full_upload_size() +
- scrollbar_layer_->last_update_partial_upload_size();
switch (commits_) {
case 1:
// First (regular) update, we should upload 2 resources (thumb, and
// backtrack).
EXPECT_EQ(1, scrollbar_layer_->update_count());
- EXPECT_EQ(2u, upload_count);
LoseContext();
break;
case 2:
// Second update, after the lost context, we should still upload 2
// resources even if the contents haven't changed.
EXPECT_EQ(2, scrollbar_layer_->update_count());
- EXPECT_EQ(2u, upload_count);
EndTest();
break;
default:
@@ -1602,5 +1599,86 @@
SINGLE_AND_MULTI_THREAD_TEST_F(
LayerTreeHostTestCannotCreateIfCannotCreateOutputSurface);
+// Test handling of lost resource with the UI resource manager.
+class UIResourceLostContext : public LayerTreeHostContextTest {
+ public:
+ UIResourceLostContext() : time_step_(0) {
+ ui_resource_client_ = new TestUIResourceClient();
+ }
+
+ virtual void BeginTest() OVERRIDE {
+ PostSetNeedsCommitToMainThread();
+ }
+
+ virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE {
+ LayerTreeHostContextTest::CommitCompleteOnThread(impl);
+ switch (time_step_) {
+ case 0:
+ ui_resource_client_->CreateResource(layer_tree_host());
+ // A valid UIResourceId.
+ EXPECT_NE(0, ui_resource_client_->id);
+ PostSetNeedsCommitToMainThread();
+ break;
+ case 1:
+ // A valid Resource Id on the impl-side.
enne (OOO) 2013/07/22 23:09:15 I'm not sure what this comment is trying to say.
powei 2013/07/24 02:28:29 Done. Changed wording.
+ if (!layer_tree_host()->settings().impl_side_painting) {
+ EXPECT_NE(0u,
+ impl->ResourceIdForUIResource(ui_resource_client_->id));
+ }
+ PostSetNeedsCommitToMainThread();
+ break;
+ case 2:
+ LoseContext();
+ // Resource Id on the impl-side should no longer be valid after
+ // context is lost.
+ EXPECT_EQ(0u,
+ impl->ResourceIdForUIResource(ui_resource_client_->id));
+ break;
+ case 3:
+ // The resources should have been recreated. The bitmap callback should
+ // have been called once with the resource_lost flag set to true.
+ EXPECT_EQ(1u, ui_resource_client_->lost_resource_count);
+ // Resource Id on the impl-side have been recreated as well. Note
+ // that the same UIResourceId persists after the context lost.
+ if (!layer_tree_host()->settings().impl_side_painting) {
+ EXPECT_NE(0u,
+ impl->ResourceIdForUIResource(ui_resource_client_->id));
+ }
+ PostSetNeedsCommitToMainThread();
+ break;
+ case 4:
+ EndTest();
+ break;
+ }
+ }
+
+ virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE {
+ LayerTreeHostContextTest::DidActivateTreeOnThread(impl);
+ switch (time_step_) {
+ case 1:
+ if (layer_tree_host()->settings().impl_side_painting) {
enne (OOO) 2013/07/22 23:09:15 Does this even get called for non-impl-side painti
powei 2013/07/24 02:28:29 Done. I wasn't sure, but apparently it does get c
+ EXPECT_NE(0u,
+ impl->ResourceIdForUIResource(ui_resource_client_->id));
+ }
+ break;
+ case 3:
+ if (layer_tree_host()->settings().impl_side_painting) {
+ EXPECT_NE(0u,
+ impl->ResourceIdForUIResource(ui_resource_client_->id));
+ }
+ break;
+ }
+ ++time_step_;
+ }
+
+ virtual void AfterTest() OVERRIDE {}
+
+ private:
+ int time_step_;
+ scoped_refptr<TestUIResourceClient> ui_resource_client_;
+};
+
+SINGLE_AND_MULTI_THREAD_TEST_F(UIResourceLostContext);
+
} // namespace
} // namespace cc

Powered by Google App Engine
This is Rietveld 408576698