| Index: ui/views/corewm/transient_window_manager_unittest.cc
|
| diff --git a/ui/views/corewm/transient_window_manager_unittest.cc b/ui/views/corewm/transient_window_manager_unittest.cc
|
| index 733cde61f690d3864af70db00c2bfc14b659248f..0e9dc40e9af3d2ed4deda40f3b1ddd6faae92f24 100644
|
| --- a/ui/views/corewm/transient_window_manager_unittest.cc
|
| +++ b/ui/views/corewm/transient_window_manager_unittest.cc
|
| @@ -9,6 +9,7 @@
|
| #include "ui/aura/layout_manager.h"
|
| #include "ui/aura/test/test_windows.h"
|
| #include "ui/aura/window.h"
|
| +#include "ui/views/corewm/transient_window_observer.h"
|
| #include "ui/views/corewm/window_util.h"
|
| #include "ui/views/test/views_test_base.h"
|
|
|
| @@ -20,6 +21,34 @@ using aura::test::CreateTestWindowWithId;
|
| namespace views {
|
| namespace corewm {
|
|
|
| +class TestTransientWindowObserver : public TransientWindowObserver {
|
| + public:
|
| + TestTransientWindowObserver() : add_count_(0), remove_count_(0) {
|
| + }
|
| +
|
| + virtual ~TestTransientWindowObserver() {
|
| + }
|
| +
|
| + int add_count() const { return add_count_; }
|
| + int remove_count() const { return remove_count_; }
|
| +
|
| + // TransientWindowObserver overrides:
|
| + virtual void OnTransientChildAdded(Window* window,
|
| + Window* transient) OVERRIDE {
|
| + add_count_++;
|
| + }
|
| + virtual void OnTransientChildRemoved(Window* window,
|
| + Window* transient) OVERRIDE {
|
| + remove_count_++;
|
| + }
|
| +
|
| + private:
|
| + int add_count_;
|
| + int remove_count_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(TestTransientWindowObserver);
|
| +};
|
| +
|
| class TransientWindowManagerTest : public views::ViewsTestBase {
|
| public:
|
| TransientWindowManagerTest() {}
|
| @@ -573,5 +602,24 @@ TEST_F(TransientWindowManagerTest, StackOverClosingTransient) {
|
| EXPECT_EQ(root->layer()->children()[3], window3->layer());
|
| }
|
|
|
| +// Verifies TransientWindowObserver is notified appropriately.
|
| +TEST_F(TransientWindowManagerTest, TransientWindowObserverNotified) {
|
| + scoped_ptr<Window> parent(CreateTestWindowWithId(0, GetContext()));
|
| + scoped_ptr<Window> w1(CreateTestWindowWithId(1, parent.get()));
|
| +
|
| + TestTransientWindowObserver test_observer;
|
| + TransientWindowManager::Get(parent.get())->AddObserver(&test_observer);
|
| +
|
| + AddTransientChild(parent.get(), w1.get());
|
| + EXPECT_EQ(1, test_observer.add_count());
|
| + EXPECT_EQ(0, test_observer.remove_count());
|
| +
|
| + RemoveTransientChild(parent.get(), w1.get());
|
| + EXPECT_EQ(1, test_observer.add_count());
|
| + EXPECT_EQ(1, test_observer.remove_count());
|
| +
|
| + TransientWindowManager::Get(parent.get())->RemoveObserver(&test_observer);
|
| +}
|
| +
|
| } // namespace corewm
|
| } // namespace views
|
|
|