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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
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 "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "ui/aura/aura_test_base.h" 8 #include "ui/aura/aura_test_base.h"
9 #include "ui/aura/desktop.h" 9 #include "ui/aura/desktop.h"
10 #include "ui/aura/event.h" 10 #include "ui/aura/event.h"
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 gfx::Rect(0, 0, 500, 500), w1.get())); 535 gfx::Rect(0, 0, 500, 500), w1.get()));
536 scoped_ptr<Window> w111(CreateTestWindowWithDelegate(&d111, 111, 536 scoped_ptr<Window> w111(CreateTestWindowWithDelegate(&d111, 111,
537 gfx::Rect(50, 50, 450, 450), w11.get())); 537 gfx::Rect(50, 50, 450, 450), w11.get()));
538 scoped_ptr<Window> w12(CreateTestWindowWithDelegate(NULL, 12, 538 scoped_ptr<Window> w12(CreateTestWindowWithDelegate(NULL, 12,
539 gfx::Rect(0, 0, 500, 500), w1.get())); 539 gfx::Rect(0, 0, 500, 500), w1.get()));
540 540
541 gfx::Point target_point = w111->bounds().CenterPoint(); 541 gfx::Point target_point = w111->bounds().CenterPoint();
542 EXPECT_EQ(w111.get(), w1->GetEventHandlerForPoint(target_point)); 542 EXPECT_EQ(w111.get(), w1->GetEventHandlerForPoint(target_point));
543 } 543 }
544 544
545 class VisibilityWindowDelegate : public TestWindowDelegate {
546 public:
547 VisibilityWindowDelegate()
548 : shown_(0),
549 hidden_(0) {
550 }
551
552 int shown() const { return shown_; }
553 int hidden() const { return hidden_; }
554 void Clear() {
555 shown_ = 0;
556 hidden_ = 0;
557 }
558
559 virtual void OnWindowVisibilityChanged(bool visible) OVERRIDE {
560 if (visible)
561 shown_++;
562 else
563 hidden_++;
564 }
565
566 private:
567 int shown_;
568 int hidden_;
569
570 DISALLOW_COPY_AND_ASSIGN(VisibilityWindowDelegate);
571 };
572
545 // Verifies show/hide propagate correctly to children and the layer. 573 // Verifies show/hide propagate correctly to children and the layer.
546 TEST_F(WindowTest, Visibility) { 574 TEST_F(WindowTest, Visibility) {
547 scoped_ptr<Window> w1(CreateTestWindowWithId(1, NULL)); 575 VisibilityWindowDelegate d;
576 scoped_ptr<Window> w1(CreateTestWindowWithDelegate(&d, 1, gfx::Rect(), NULL));
548 scoped_ptr<Window> w2(CreateTestWindowWithId(2, w1.get())); 577 scoped_ptr<Window> w2(CreateTestWindowWithId(2, w1.get()));
549 scoped_ptr<Window> w3(CreateTestWindowWithId(3, w2.get())); 578 scoped_ptr<Window> w3(CreateTestWindowWithId(3, w2.get()));
550 579
551 // Create shows all the windows. 580 // Create shows all the windows.
552 EXPECT_TRUE(w1->IsVisible()); 581 EXPECT_TRUE(w1->IsVisible());
553 EXPECT_TRUE(w2->IsVisible()); 582 EXPECT_TRUE(w2->IsVisible());
554 EXPECT_TRUE(w3->IsVisible()); 583 EXPECT_TRUE(w3->IsVisible());
584 EXPECT_EQ(1, d.shown());
555 585
586 d.Clear();
556 w1->Hide(); 587 w1->Hide();
557 EXPECT_FALSE(w1->IsVisible()); 588 EXPECT_FALSE(w1->IsVisible());
558 EXPECT_FALSE(w2->IsVisible()); 589 EXPECT_FALSE(w2->IsVisible());
559 EXPECT_FALSE(w3->IsVisible()); 590 EXPECT_FALSE(w3->IsVisible());
591 EXPECT_EQ(1, d.hidden());
592 EXPECT_EQ(0, d.shown());
560 593
561 w2->Show(); 594 w2->Show();
562 EXPECT_FALSE(w1->IsVisible()); 595 EXPECT_FALSE(w1->IsVisible());
563 EXPECT_FALSE(w2->IsVisible()); 596 EXPECT_FALSE(w2->IsVisible());
564 EXPECT_FALSE(w3->IsVisible()); 597 EXPECT_FALSE(w3->IsVisible());
565 598
566 w3->Hide(); 599 w3->Hide();
567 EXPECT_FALSE(w1->IsVisible()); 600 EXPECT_FALSE(w1->IsVisible());
568 EXPECT_FALSE(w2->IsVisible()); 601 EXPECT_FALSE(w2->IsVisible());
569 EXPECT_FALSE(w3->IsVisible()); 602 EXPECT_FALSE(w3->IsVisible());
570 603
604 d.Clear();
571 w1->Show(); 605 w1->Show();
572 EXPECT_TRUE(w1->IsVisible()); 606 EXPECT_TRUE(w1->IsVisible());
573 EXPECT_TRUE(w2->IsVisible()); 607 EXPECT_TRUE(w2->IsVisible());
574 EXPECT_FALSE(w3->IsVisible()); 608 EXPECT_FALSE(w3->IsVisible());
609 EXPECT_EQ(0, d.hidden());
610 EXPECT_EQ(1, d.shown());
575 611
576 w3->Show(); 612 w3->Show();
577 EXPECT_TRUE(w1->IsVisible()); 613 EXPECT_TRUE(w1->IsVisible());
578 EXPECT_TRUE(w2->IsVisible()); 614 EXPECT_TRUE(w2->IsVisible());
579 EXPECT_TRUE(w3->IsVisible()); 615 EXPECT_TRUE(w3->IsVisible());
580 } 616 }
581 617
582 // When set_consume_events() is called with |true| for a Window, that Window 618 // When set_consume_events() is called with |true| for a Window, that Window
583 // should make sure that none behind it in the z-order see events if it has 619 // should make sure that none behind it in the z-order see events if it has
584 // children. If it does not have children, event targeting works as usual. 620 // children. If it does not have children, event targeting works as usual.
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
718 754
719 // Deactivate w1 and make sure w2 becomes active and frontmost. 755 // Deactivate w1 and make sure w2 becomes active and frontmost.
720 w1->Deactivate(); 756 w1->Deactivate();
721 EXPECT_FALSE(w1->IsActive()); 757 EXPECT_FALSE(w1->IsActive());
722 EXPECT_TRUE(w2->IsActive()); 758 EXPECT_TRUE(w2->IsActive());
723 EXPECT_EQ(w2.get(), parent->children()[1]); 759 EXPECT_EQ(w2.get(), parent->children()[1]);
724 } 760 }
725 761
726 } // namespace internal 762 } // namespace internal
727 } // namespace aura 763 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698