diff options
author | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-02 23:24:45 +0000 |
---|---|---|
committer | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-02 23:24:45 +0000 |
commit | cce34bd6de099e68afdedba4ed8cd5f4e67c4cf8 (patch) | |
tree | 1091f35b17fb6b979b70d455b8d42e4deb878c16 /cc/layers | |
parent | 015c7adac7753177f0b047223773262cfbadf1d1 (diff) | |
download | chromium_src-cce34bd6de099e68afdedba4ed8cd5f4e67c4cf8.zip chromium_src-cce34bd6de099e68afdedba4ed8cd5f4e67c4cf8.tar.gz chromium_src-cce34bd6de099e68afdedba4ed8cd5f4e67c4cf8.tar.bz2 |
cc: Fix the TextureLayerNoExtraCommitForMailboxTest test.
The test puts a mailbox into the compositor tree and then makes sure
only one commit is scheduled.
Right now the test does this by just doing EndTest() and verifying
that a 2nd commit doesn't happen before the test exits. This causes
a crash though when the mailbox is destroyed before being cleaned
up properly, and then the release callback runs on a bad test
pointer.
Instead, we can have the test make use of CommitPendingForTesting()
to verify another commit was not scheduled, then have it remove the
mailbox from the tree as other tests do.
R=enne
BUG=317854
Review URL: https://codereview.chromium.org/99913003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@238227 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/layers')
-rw-r--r-- | cc/layers/texture_layer_unittest.cc | 60 |
1 files changed, 35 insertions, 25 deletions
diff --git a/cc/layers/texture_layer_unittest.cc b/cc/layers/texture_layer_unittest.cc index 373f62d..5b3955e 100644 --- a/cc/layers/texture_layer_unittest.cc +++ b/cc/layers/texture_layer_unittest.cc @@ -1683,40 +1683,30 @@ class TextureLayerNoExtraCommitForMailboxTest : public LayerTreeTest, public TextureLayerClient { public: - TextureLayerNoExtraCommitForMailboxTest() - : prepare_mailbox_count_(0) {} - // TextureLayerClient implementation. virtual unsigned PrepareTexture() OVERRIDE { NOTREACHED(); return 0; } - virtual bool PrepareTextureMailbox( - cc::TextureMailbox* mailbox, + TextureMailbox* mailbox, scoped_ptr<SingleReleaseCallback>* release_callback, bool use_shared_memory) OVERRIDE { - prepare_mailbox_count_++; - // Alternate between two mailboxes to ensure that the TextureLayer updates - // and commits. - if (prepare_mailbox_count_ % 2 == 0) - *mailbox = MakeMailbox('1'); - else - *mailbox = MakeMailbox('2'); + if (layer_tree_host()->source_frame_number() == 1) { + *mailbox = TextureMailbox(); + return true; + } - // Non-zero mailboxes need a callback. + *mailbox = TextureMailbox(std::string(64, '1')); *release_callback = SingleReleaseCallback::Create( base::Bind(&TextureLayerNoExtraCommitForMailboxTest::MailboxReleased, base::Unretained(this))); - // If the test fails, this would cause an infinite number of commits. return true; } - TextureMailbox MakeMailbox(char name) { - return TextureMailbox(std::string(64, name)); - } - void MailboxReleased(unsigned sync_point, bool lost_resource) { + EXPECT_EQ(2, layer_tree_host()->source_frame_number()); + EndTest(); } virtual void SetupTree() OVERRIDE { @@ -1750,11 +1740,15 @@ class TextureLayerNoExtraCommitForMailboxTest PostSetNeedsCommitToMainThread(); } - - virtual void DidCommit() OVERRIDE { + virtual void DidCommitAndDrawFrame() OVERRIDE { switch (layer_tree_host()->source_frame_number()) { case 1: - EndTest(); + EXPECT_FALSE(proxy()->CommitPendingForTesting()); + // Invalidate the texture layer to clear the mailbox before + // ending the test. + texture_layer_->SetNeedsDisplay(); + break; + case 2: break; default: NOTREACHED(); @@ -1762,18 +1756,34 @@ class TextureLayerNoExtraCommitForMailboxTest } } + virtual void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, + bool result) OVERRIDE { + ASSERT_TRUE(result); + DelegatedFrameData* delegated_frame_data = + output_surface()->last_sent_frame().delegated_frame_data.get(); + if (!delegated_frame_data) + return; + + // Return all resources immediately. + TransferableResourceArray resources_to_return = + output_surface()->resources_held_by_parent(); + + CompositorFrameAck ack; + for (size_t i = 0; i < resources_to_return.size(); ++i) + output_surface()->ReturnResource(resources_to_return[i].id, &ack); + host_impl->ReclaimResources(&ack); + host_impl->OnSwapBuffersComplete(); + } + virtual void AfterTest() OVERRIDE {} private: scoped_refptr<SolidColorLayer> solid_layer_; scoped_refptr<Layer> parent_layer_; scoped_refptr<TextureLayer> texture_layer_; - - int prepare_mailbox_count_; }; -// Disabled, crashes: http://crbug.com/317854 . -// SINGLE_AND_MULTI_THREAD_TEST_F(TextureLayerNoExtraCommitForMailboxTest); +SINGLE_AND_MULTI_THREAD_TEST_F(TextureLayerNoExtraCommitForMailboxTest); // Checks that changing a mailbox in the client for a TextureLayer that's // invisible correctly works and uses the new mailbox as soon as the layer |