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

Unified Diff: ui/aura/window_unittest.cc

Issue 8253001: aura: Some changes in Window and Desktop. (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
« no previous file with comments | « ui/aura/desktop_observer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/aura/window_unittest.cc
diff --git a/ui/aura/window_unittest.cc b/ui/aura/window_unittest.cc
index 1494ba7522a3a10caacd32b2609c30b4a2963a02..cbd2e950557cfb4327124f50b15b4aaec16d29bc 100644
--- a/ui/aura/window_unittest.cc
+++ b/ui/aura/window_unittest.cc
@@ -6,6 +6,7 @@
#include "base/compiler_specific.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/aura/desktop.h"
+#include "ui/aura/desktop_observer.h"
#include "ui/aura/event.h"
#include "ui/aura/focus_manager.h"
#include "ui/aura/hit_test.h"
@@ -760,5 +761,57 @@ TEST_F(WindowTest, Deactivate) {
EXPECT_EQ(w2.get(), parent->children()[1]);
}
+class ObserverTest : public WindowTest,
+ public DesktopObserver {
+ public:
+ ObserverTest()
+ : active_(NULL) {
+ }
+
+ virtual ~ObserverTest() {}
+
+ Window* active() const { return active_; }
+
+ void Reset() {
+ active_ = NULL;
+ }
+
+ private:
+ virtual void SetUp() OVERRIDE {
+ WindowTest::SetUp();
+ Desktop::GetInstance()->AddObserver(this);
+ }
+
+ virtual void TearDown() OVERRIDE {
+ Desktop::GetInstance()->RemoveObserver(this);
+ WindowTest::TearDown();
+ }
+
+ virtual void OnActiveWindowChanged(Window* active) OVERRIDE {
+ active_ = active;
+ }
+
+ Window* active_;
+
+ DISALLOW_COPY_AND_ASSIGN(ObserverTest);
+};
+
+TEST_F(ObserverTest, WindowActivationObserve) {
+ scoped_ptr<Window> w1(CreateTestWindowWithId(1, NULL));
+ scoped_ptr<Window> w2(CreateTestWindowWithId(2, NULL));
+ scoped_ptr<Window> w3(CreateTestWindowWithId(3, w1.get()));
+
+ EXPECT_EQ(NULL, active());
+
+ w2->Activate();
+ EXPECT_EQ(w2.get(), active());
+
+ w3->Activate();
+ EXPECT_EQ(w2.get(), active());
+
+ w1->Activate();
+ EXPECT_EQ(w1.get(), active());
+}
+
} // namespace test
} // namespace aura
« no previous file with comments | « ui/aura/desktop_observer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698