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

Unified Diff: cc/layer_tree_host_unittest.cc

Issue 11571049: cc: Make the scheduler compositeAndReadback flow not race with WAITING_FOR_FIRST_DRAW (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: indents Created 8 years 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
« no previous file with comments | « no previous file | cc/scheduler_state_machine.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/layer_tree_host_unittest.cc
diff --git a/cc/layer_tree_host_unittest.cc b/cc/layer_tree_host_unittest.cc
index f2bf6dd2e9c7466d9ba70d25026dccdf6a961919..ba9e88d62acd6c90c1c3c098237e907795c485ea 100644
--- a/cc/layer_tree_host_unittest.cc
+++ b/cc/layer_tree_host_unittest.cc
@@ -278,6 +278,88 @@ TEST_F(LayerTreeHostTestSetNeedsRedraw, runMultiThread)
runTest(true);
}
+class LayerTreeHostTestCompositeAndReadback : public LayerTreeHostTest {
+public:
+ LayerTreeHostTestCompositeAndReadback()
+ : m_numCommits(0)
+ {
+ }
+
+ virtual void beginTest() OVERRIDE
+ {
+ postSetNeedsCommitToMainThread();
+ }
+
+ virtual void didCommit() OVERRIDE
+ {
+ m_numCommits++;
+ if (m_numCommits == 1) {
+ char pixels[4];
+ m_layerTreeHost->compositeAndReadback(static_cast<void*>(&pixels), gfx::Rect(0, 0, 1, 1));
+ } else if (m_numCommits == 2) {
+ // This is inside the readback. We should get another commit after it.
+ } else if (m_numCommits == 3) {
+ endTest();
+ } else {
+ NOTREACHED();
+ }
+ }
+
+ virtual void afterTest() OVERRIDE
+ {
+ }
+
+private:
+ int m_numCommits;
+};
+
+TEST_F(LayerTreeHostTestCompositeAndReadback, runMultiThread)
+{
+ runTest(true);
+}
+
+class LayerTreeHostTestCompositeAndReadbackBeforePreviousCommitDraws : public LayerTreeHostTest {
+public:
+ LayerTreeHostTestCompositeAndReadbackBeforePreviousCommitDraws()
+ : m_numCommits(0)
+ {
+ }
+
+ virtual void beginTest() OVERRIDE
+ {
+ postSetNeedsCommitToMainThread();
+ }
+
+ virtual void didCommit() OVERRIDE
+ {
+ m_numCommits++;
+ if (m_numCommits == 1) {
+ m_layerTreeHost->setNeedsCommit();
+ } else if (m_numCommits == 2) {
+ char pixels[4];
+ m_layerTreeHost->compositeAndReadback(static_cast<void*>(&pixels), gfx::Rect(0, 0, 1, 1));
+ } else if (m_numCommits == 3) {
+ // This is inside the readback. We should get another commit after it.
+ } else if (m_numCommits == 4) {
+ endTest();
+ } else {
+ NOTREACHED();
+ }
+ }
+
+ virtual void afterTest() OVERRIDE
+ {
+ }
+
+private:
+ int m_numCommits;
+};
+
+TEST_F(LayerTreeHostTestCompositeAndReadbackBeforePreviousCommitDraws, runMultiThread)
+{
+ runTest(true);
+}
+
// If the layerTreeHost says it can't draw, then we should not try to draw.
class LayerTreeHostTestCanDrawBlocksDrawing : public LayerTreeHostTest {
public:
@@ -321,9 +403,6 @@ public:
char pixels[4];
m_layerTreeHost->compositeAndReadback(static_cast<void*>(&pixels), gfx::Rect(0, 0, 1, 1));
} else if (m_numCommits == 3) {
- postSetNeedsRedrawToMainThread();
- postSetNeedsCommitToMainThread();
- } else if (m_numCommits == 4) {
// Let it draw so we go idle and end the test.
m_layerTreeHost->setViewportSize(gfx::Size(1, 1), gfx::Size(1, 1));
m_done = true;
« no previous file with comments | « no previous file | cc/scheduler_state_machine.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698