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

Unified Diff: ui/aura/window_unittest.cc

Issue 8247012: Positions the launcher in the bottom left corner. Adds ShellDelegate (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Tweaks 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/window_observer.h ('k') | ui/aura_shell/aura_shell.gyp » ('j') | 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..c26053580362cdc89cad6be57cf29527f14e0023 100644
--- a/ui/aura/window_unittest.cc
+++ b/ui/aura/window_unittest.cc
@@ -2,8 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "ui/aura/window.h"
+
#include "base/basictypes.h"
#include "base/compiler_specific.h"
+#include "base/stringprintf.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/aura/desktop.h"
#include "ui/aura/event.h"
@@ -14,6 +17,7 @@
#include "ui/aura/test/test_desktop_delegate.h"
#include "ui/aura/test/test_window_delegate.h"
#include "ui/aura/window_delegate.h"
+#include "ui/aura/window_observer.h"
#include "ui/gfx/canvas_skia.h"
#include "ui/gfx/compositor/layer.h"
#include "ui/base/keycodes/keyboard_codes.h"
@@ -760,5 +764,60 @@ TEST_F(WindowTest, Deactivate) {
EXPECT_EQ(w2.get(), parent->children()[1]);
}
+class ObserverTest : public WindowTest,
+ public WindowObserver {
+ public:
+ ObserverTest() : added_count_(0), removed_count_(0) {}
+
+ virtual ~ObserverTest() {}
+
+ // Returns a description of the WindowObserver methods that have been invoked.
+ std::string WindowObserverCountStateAndClear() {
+ std::string result(
+ base::StringPrintf("added=%d removed=%d",
+ added_count_, removed_count_));
+ added_count_ = removed_count_ = 0;
+ return result;
+ }
+
+ private:
+ virtual void OnWindowAdded(Window* new_window) OVERRIDE {
+ added_count_++;
+ }
+
+ virtual void OnWillRemoveWindow(Window* window) OVERRIDE {
+ removed_count_++;
+ }
+
+ int added_count_;
+ int removed_count_;
+
+ DISALLOW_COPY_AND_ASSIGN(ObserverTest);
+};
+
+// Various assertions for WindowObserver.
+TEST_F(ObserverTest, WindowObserver) {
+ scoped_ptr<Window> w1(CreateTestWindowWithId(1, NULL));
+ w1->AddObserver(this);
+
+ // Create a new window as a child of w1, our observer should be notified.
+ scoped_ptr<Window> w2(CreateTestWindowWithId(2, w1.get()));
+ EXPECT_EQ("added=1 removed=0", WindowObserverCountStateAndClear());
+
+ // Delete w2, which should result in the remove notification.
+ w2.reset();
+ EXPECT_EQ("added=0 removed=1", WindowObserverCountStateAndClear());
+
+ // Create a window that isn't parented to w1, we shouldn't get any
+ // notification.
+ scoped_ptr<Window> w3(CreateTestWindowWithId(3, NULL));
+ EXPECT_EQ("added=0 removed=0", WindowObserverCountStateAndClear());
+
+ // Similarly destroying w3 shouldn't notify us either.
+ w3.reset();
+ EXPECT_EQ("added=0 removed=0", WindowObserverCountStateAndClear());
+ w1->RemoveObserver(this);
+}
+
} // namespace test
} // namespace aura
« no previous file with comments | « ui/aura/window_observer.h ('k') | ui/aura_shell/aura_shell.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698