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

Side by Side Diff: ui/gfx/compositor/layer_unittest.cc

Issue 8515006: A fix for LayerNoTextureSetFillsBoundsOpaquely. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/gfx/compositor/layer.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/compiler_specific.h" 6 #include "base/compiler_specific.h"
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "ui/gfx/canvas_skia.h" 9 #include "ui/gfx/canvas_skia.h"
10 #include "ui/gfx/compositor/compositor_observer.h" 10 #include "ui/gfx/compositor/compositor_observer.h"
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 layer->SetBounds(bounds); 458 layer->SetBounds(bounds);
459 return layer; 459 return layer;
460 } 460 }
461 461
462 Layer* CreateNoTextureLayer(const gfx::Rect& bounds) OVERRIDE { 462 Layer* CreateNoTextureLayer(const gfx::Rect& bounds) OVERRIDE {
463 Layer* layer = CreateLayer(Layer::LAYER_HAS_NO_TEXTURE); 463 Layer* layer = CreateLayer(Layer::LAYER_HAS_NO_TEXTURE);
464 layer->SetBounds(bounds); 464 layer->SetBounds(bounds);
465 return layer; 465 return layer;
466 } 466 }
467 467
468 void RunPendingMessages() {
469 MessageLoopForUI::current()->RunAllPending();
470 }
471
468 private: 472 private:
469 scoped_ptr<NullLayerDelegate> default_layer_delegate_; 473 scoped_ptr<NullLayerDelegate> default_layer_delegate_;
470 474
471 DISALLOW_COPY_AND_ASSIGN(LayerWithNullDelegateTest); 475 DISALLOW_COPY_AND_ASSIGN(LayerWithNullDelegateTest);
472 }; 476 };
473 477
474 // Verifies that a layer which is set never to have a texture does not 478 // Verifies that a layer which is set never to have a texture does not
475 // get a texture when SetFillsBoundsOpaquely is called. 479 // get a texture when SetFillsBoundsOpaquely is called.
476 TEST_F(LayerWithNullDelegateTest, LayerNoTextureSetFillsBoundsOpaquely) { 480 TEST_F(LayerWithNullDelegateTest, LayerNoTextureSetFillsBoundsOpaquely) {
477 scoped_ptr<Layer> parent(CreateNoTextureLayer(gfx::Rect(0, 0, 400, 400))); 481 scoped_ptr<Layer> parent(CreateNoTextureLayer(gfx::Rect(0, 0, 400, 400)));
478 scoped_ptr<Layer> child(CreateNoTextureLayer(gfx::Rect(50, 50, 100, 100))); 482 scoped_ptr<Layer> child(CreateNoTextureLayer(gfx::Rect(50, 50, 100, 100)));
479 parent->Add(child.get()); 483 parent->Add(child.get());
480 484
481 compositor()->SetRootLayer(parent.get()); 485 compositor()->SetRootLayer(parent.get());
486 parent->SetFillsBoundsOpaquely(true);
sky 2011/11/10 20:20:53 Why should this matter if the layer has texture?
487 child->SetFillsBoundsOpaquely(true);
482 Draw(); 488 Draw();
489 RunPendingMessages();
490 EXPECT_TRUE(child->texture() == NULL);
491 EXPECT_TRUE(parent->texture() == NULL);
492
493 parent->SetFillsBoundsOpaquely(false);
494 child->SetFillsBoundsOpaquely(false);
495 Draw();
496 RunPendingMessages();
483 EXPECT_TRUE(child->texture() == NULL); 497 EXPECT_TRUE(child->texture() == NULL);
484 EXPECT_TRUE(parent->texture() == NULL); 498 EXPECT_TRUE(parent->texture() == NULL);
485 } 499 }
486 500
487 // With the webkit compositor, we don't explicitly textures for layers, making 501 // With the webkit compositor, we don't explicitly textures for layers, making
488 // tests that check that we do fail. 502 // tests that check that we do fail.
489 #if defined(USE_WEBKIT_COMPOSITOR) 503 #if defined(USE_WEBKIT_COMPOSITOR)
490 #define WEBKIT_COMPOSITOR_FAILS(X) FAILS_ ## X 504 #define WEBKIT_COMPOSITOR_FAILS(X) FAILS_ ## X
491 #else 505 #else
492 #define WEBKIT_COMPOSITOR_FAILS(X) X 506 #define WEBKIT_COMPOSITOR_FAILS(X) X
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
782 SkAutoLockPixels lock(bitmap); 796 SkAutoLockPixels lock(bitmap);
783 bool is_all_red = true; 797 bool is_all_red = true;
784 for (int x = 0; is_all_red && x < 500; x++) 798 for (int x = 0; is_all_red && x < 500; x++)
785 for (int y = 0; is_all_red && y < 500; y++) 799 for (int y = 0; is_all_red && y < 500; y++)
786 is_all_red = is_all_red && (bitmap.getColor(x, y) == SK_ColorRED); 800 is_all_red = is_all_red && (bitmap.getColor(x, y) == SK_ColorRED);
787 801
788 EXPECT_TRUE(is_all_red); 802 EXPECT_TRUE(is_all_red);
789 } 803 }
790 804
791 } // namespace ui 805 } // namespace ui
OLDNEW
« no previous file with comments | « ui/gfx/compositor/layer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698