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

Unified Diff: ui/aura/window_unittest.cc

Issue 8202026: views: Some more layer change, and add/update some tests for layers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years, 2 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: ui/aura/window_unittest.cc
diff --git a/ui/aura/window_unittest.cc b/ui/aura/window_unittest.cc
index 3cca1da0379149c19b36d20ab6c3b07a46651173..43ad68f6ed223462012d52722ebc157cee892536 100644
--- a/ui/aura/window_unittest.cc
+++ b/ui/aura/window_unittest.cc
@@ -542,9 +542,38 @@ TEST_F(WindowTest, GetEventHandlerForPoint_NoDelegate) {
EXPECT_EQ(w111.get(), w1->GetEventHandlerForPoint(target_point));
}
+class VisibilityWindowDelegate : public TestWindowDelegate {
+ public:
+ VisibilityWindowDelegate()
+ : shown_(0),
+ hidden_(0) {
+ }
+
+ int shown() const { return shown_; }
+ int hidden() const { return hidden_; }
+ void Clear() {
+ shown_ = 0;
+ hidden_ = 0;
+ }
+
+ virtual void OnWindowVisibilityChanged(bool visible) OVERRIDE {
+ if (visible)
+ shown_++;
+ else
+ hidden_++;
+ }
+
+ private:
+ int shown_;
+ int hidden_;
+
+ DISALLOW_COPY_AND_ASSIGN(VisibilityWindowDelegate);
+};
+
// Verifies show/hide propagate correctly to children and the layer.
TEST_F(WindowTest, Visibility) {
- scoped_ptr<Window> w1(CreateTestWindowWithId(1, NULL));
+ VisibilityWindowDelegate d;
+ scoped_ptr<Window> w1(CreateTestWindowWithDelegate(&d, 1, gfx::Rect(), NULL));
scoped_ptr<Window> w2(CreateTestWindowWithId(2, w1.get()));
scoped_ptr<Window> w3(CreateTestWindowWithId(3, w2.get()));
@@ -552,11 +581,15 @@ TEST_F(WindowTest, Visibility) {
EXPECT_TRUE(w1->IsVisible());
EXPECT_TRUE(w2->IsVisible());
EXPECT_TRUE(w3->IsVisible());
+ EXPECT_EQ(1, d.shown());
+ d.Clear();
w1->Hide();
EXPECT_FALSE(w1->IsVisible());
EXPECT_FALSE(w2->IsVisible());
EXPECT_FALSE(w3->IsVisible());
+ EXPECT_EQ(1, d.hidden());
+ EXPECT_EQ(0, d.shown());
w2->Show();
EXPECT_FALSE(w1->IsVisible());
@@ -568,10 +601,13 @@ TEST_F(WindowTest, Visibility) {
EXPECT_FALSE(w2->IsVisible());
EXPECT_FALSE(w3->IsVisible());
+ d.Clear();
w1->Show();
EXPECT_TRUE(w1->IsVisible());
EXPECT_TRUE(w2->IsVisible());
EXPECT_FALSE(w3->IsVisible());
+ EXPECT_EQ(0, d.hidden());
+ EXPECT_EQ(1, d.shown());
w3->Show();
EXPECT_TRUE(w1->IsVisible());

Powered by Google App Engine
This is Rietveld 408576698