summaryrefslogtreecommitdiffstats
path: root/ui/aura
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-01 22:08:15 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-01 22:08:15 +0000
commit5a9374b19b1be32b4abfffb0a304f28ec6ccc72a (patch)
tree535c17c5a04be2959afffbe42288502b3745fd32 /ui/aura
parentf32a8b30d6a18fa29e0a9ee5596eeae620a76599 (diff)
downloadchromium_src-5a9374b19b1be32b4abfffb0a304f28ec6ccc72a.zip
chromium_src-5a9374b19b1be32b4abfffb0a304f28ec6ccc72a.tar.gz
chromium_src-5a9374b19b1be32b4abfffb0a304f28ec6ccc72a.tar.bz2
Gets disable inactive frame rendering to work correctly for aura. This
is needed for bubbles. BUG=none TEST=none R=ben@chromium.org Review URL: http://codereview.chromium.org/8351042 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@108179 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/aura')
-rw-r--r--ui/aura/desktop.cc8
-rw-r--r--ui/aura/window_unittest.cc59
2 files changed, 65 insertions, 2 deletions
diff --git a/ui/aura/desktop.cc b/ui/aura/desktop.cc
index 2c747d2..a6c909a 100644
--- a/ui/aura/desktop.cc
+++ b/ui/aura/desktop.cc
@@ -362,9 +362,13 @@ void Desktop::SetActiveWindow(Window* window, Window* to_focus) {
if (active_window_ == window)
return;
- if (active_window_ && active_window_->delegate())
- active_window_->delegate()->OnLostActive();
+ Window* old_active = active_window_;
active_window_ = window;
+ // Invoke OnLostActive after we've changed the active window. That way if the
+ // delegate queries for active state it doesn't think the window is still
+ // active.
+ if (old_active && old_active->delegate())
+ old_active->delegate()->OnLostActive();
if (active_window_) {
active_window_->parent()->MoveChildToFront(active_window_);
if (active_window_->delegate())
diff --git a/ui/aura/window_unittest.cc b/ui/aura/window_unittest.cc
index 80b25c2..4159d83 100644
--- a/ui/aura/window_unittest.cc
+++ b/ui/aura/window_unittest.cc
@@ -693,6 +693,65 @@ TEST_F(WindowTest, ActivateOnTouch) {
EXPECT_EQ(0, d1.lost_active_count());
}
+namespace {
+
+class ActiveWindowDelegate : public TestWindowDelegate {
+ public:
+ ActiveWindowDelegate() : window_(NULL), was_active_(false), hit_count_(0) {
+ }
+
+ void set_window(Window* window) { window_ = window; }
+
+ // Number of times OnLostActive has been invoked.
+ int hit_count() const { return hit_count_; }
+
+ // Was the window active from the first call to OnLostActive?
+ bool was_active() const { return was_active_; }
+
+ virtual void OnLostActive() OVERRIDE {
+ if (hit_count_++ == 0)
+ was_active_ = window_->IsActive();
+ }
+
+ private:
+ Window* window_;
+
+ // See description above getters for details on these.
+ bool was_active_;
+ int hit_count_;
+
+ DISALLOW_COPY_AND_ASSIGN(ActiveWindowDelegate);
+};
+
+} // namespace
+
+// Verifies that when WindowDelegate::OnLostActive is invoked the window is not
+// active.
+TEST_F(WindowTest, NotActiveInLostActive) {
+ Desktop* desktop = Desktop::GetInstance();
+
+ ActiveWindowDelegate d1;
+ scoped_ptr<Window> w1(
+ CreateTestWindowWithDelegate(&d1, 1, gfx::Rect(10, 10, 50, 50), NULL));
+ d1.set_window(w1.get());
+
+ // Activate w1.
+ desktop->SetActiveWindow(w1.get(), NULL);
+ EXPECT_EQ(w1.get(), desktop->active_window());
+
+ // Should not have gotten a OnLostActive yet.
+ EXPECT_EQ(0, d1.hit_count());
+
+ // Change the active window to NULL.
+ desktop->SetActiveWindow(NULL, NULL);
+ EXPECT_TRUE(desktop->active_window() == NULL);
+
+ // Should have gotten OnLostActive and w1 should not have been active at that
+ // time.
+ EXPECT_EQ(1, d1.hit_count());
+ EXPECT_FALSE(d1.was_active());
+}
+
// Creates a window with a delegate (w111) that can handle events at a lower
// z-index than a window without a delegate (w12). w12 is sized to fill the
// entire bounds of the container. This test verifies that