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

Side by Side Diff: ui/aura/window_unittest.cc

Issue 8351042: Gets disable inactive frame rendering to work correctly for aura. This (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Tweaks 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
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 "ui/aura/window.h" 5 #include "ui/aura/window.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/stringprintf.h" 9 #include "base/stringprintf.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 d1.set_activate(true); 687 d1.set_activate(true);
688 w2.reset(); 688 w2.reset();
689 EXPECT_EQ(0, d2.activated_count()); 689 EXPECT_EQ(0, d2.activated_count());
690 EXPECT_EQ(0, d2.lost_active_count()); 690 EXPECT_EQ(0, d2.lost_active_count());
691 EXPECT_EQ(w1.get(), desktop->active_window()); 691 EXPECT_EQ(w1.get(), desktop->active_window());
692 EXPECT_EQ(w1.get(), focus_manager->GetFocusedWindow()); 692 EXPECT_EQ(w1.get(), focus_manager->GetFocusedWindow());
693 EXPECT_EQ(1, d1.activated_count()); 693 EXPECT_EQ(1, d1.activated_count());
694 EXPECT_EQ(0, d1.lost_active_count()); 694 EXPECT_EQ(0, d1.lost_active_count());
695 } 695 }
696 696
697 namespace {
698
699 class ActiveWindowDelegate : public TestWindowDelegate {
700 public:
701 ActiveWindowDelegate() : window_(NULL), was_active_(false), hit_count_(0) {
702 }
703
704 void set_window(Window* window) { window_ = window; }
705
706 // Number of times OnLostActive has been invoked.
707 int hit_count() const { return hit_count_; }
708
709 // Was the window active from the first call to OnLostActive?
710 bool was_active() const { return was_active_; }
711
712 virtual void OnLostActive() OVERRIDE {
713 if (hit_count_++ == 0)
714 was_active_ = window_->IsActive();
715 }
716
717 private:
718 Window* window_;
719
720 // See description above getters for details on these.
721 bool was_active_;
722 int hit_count_;
723
724 DISALLOW_COPY_AND_ASSIGN(ActiveWindowDelegate);
725 };
726
727 } // namespace
728
729 // Verifies that when WindowDelegate::OnLostActive is invoked the window is not
730 // active.
731 TEST_F(WindowTest, NotActiveInLostActive) {
732 Desktop* desktop = Desktop::GetInstance();
733
734 ActiveWindowDelegate d1;
735 scoped_ptr<Window> w1(
736 CreateTestWindowWithDelegate(&d1, 1, gfx::Rect(10, 10, 50, 50), NULL));
737 d1.set_window(w1.get());
738
739 // Activate w1.
740 desktop->SetActiveWindow(w1.get(), NULL);
741 EXPECT_EQ(w1.get(), desktop->active_window());
742
743 // Should not have gotten a OnLostActive yet.
744 EXPECT_EQ(0, d1.hit_count());
745
746 // Change the active window to NULL.
747 desktop->SetActiveWindow(NULL, NULL);
748 EXPECT_TRUE(desktop->active_window() == NULL);
749
750 // Should have gotten OnLostActive and w1 should not have been active at that
751 // time.
752 EXPECT_EQ(1, d1.hit_count());
753 EXPECT_FALSE(d1.was_active());
754 }
755
697 // Creates a window with a delegate (w111) that can handle events at a lower 756 // Creates a window with a delegate (w111) that can handle events at a lower
698 // z-index than a window without a delegate (w12). w12 is sized to fill the 757 // z-index than a window without a delegate (w12). w12 is sized to fill the
699 // entire bounds of the container. This test verifies that 758 // entire bounds of the container. This test verifies that
700 // GetEventHandlerForPoint() skips w12 even though its bounds contain the event, 759 // GetEventHandlerForPoint() skips w12 even though its bounds contain the event,
701 // because it has no children that can handle the event and it has no delegate 760 // because it has no children that can handle the event and it has no delegate
702 // allowing it to handle the event itself. 761 // allowing it to handle the event itself.
703 TEST_F(WindowTest, GetEventHandlerForPoint_NoDelegate) { 762 TEST_F(WindowTest, GetEventHandlerForPoint_NoDelegate) {
704 TestWindowDelegate d111; 763 TestWindowDelegate d111;
705 scoped_ptr<Window> w1(CreateTestWindowWithDelegate(NULL, 1, 764 scoped_ptr<Window> w1(CreateTestWindowWithDelegate(NULL, 1,
706 gfx::Rect(0, 0, 500, 500), NULL)); 765 gfx::Rect(0, 0, 500, 500), NULL));
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after
1362 1421
1363 w3->Activate(); 1422 w3->Activate();
1364 EXPECT_EQ(w2.get(), active()); 1423 EXPECT_EQ(w2.get(), active());
1365 1424
1366 w1->Activate(); 1425 w1->Activate();
1367 EXPECT_EQ(w1.get(), active()); 1426 EXPECT_EQ(w1.get(), active());
1368 } 1427 }
1369 1428
1370 } // namespace test 1429 } // namespace test
1371 } // namespace aura 1430 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698