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

Side by Side Diff: ui/wm/core/transient_window_manager_unittest.cc

Issue 2453953003: Moves TransientWindowClient to ui/aura/client and adds observer (Closed)
Patch Set: merge Created 4 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
« no previous file with comments | « ui/wm/core/transient_window_manager.cc ('k') | ui/wm/core/wm_state.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/wm/core/transient_window_manager.h" 5 #include "ui/wm/core/transient_window_manager.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "ui/aura/client/window_parenting_client.h" 10 #include "ui/aura/client/window_parenting_client.h"
11 #include "ui/aura/test/aura_test_base.h" 11 #include "ui/aura/test/aura_test_base.h"
12 #include "ui/aura/test/test_windows.h" 12 #include "ui/aura/test/test_windows.h"
13 #include "ui/aura/window.h" 13 #include "ui/aura/window.h"
14 #include "ui/aura/window_observer.h" 14 #include "ui/aura/window_observer.h"
15 #include "ui/wm/core/transient_window_observer.h" 15 #include "ui/wm/core/transient_window_observer.h"
16 #include "ui/wm/core/window_util.h" 16 #include "ui/wm/core/window_util.h"
17 #include "ui/wm/core/wm_state.h"
18 17
19 using aura::Window; 18 using aura::Window;
20 19
21 using aura::test::ChildWindowIDsAsString; 20 using aura::test::ChildWindowIDsAsString;
22 using aura::test::CreateTestWindowWithId; 21 using aura::test::CreateTestWindowWithId;
23 22
24 namespace wm { 23 namespace wm {
25 24
26 class TestTransientWindowObserver : public TransientWindowObserver { 25 class TestTransientWindowObserver : public TransientWindowObserver {
27 public: 26 public:
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 std::unique_ptr<Window> owned_window_; 67 std::unique_ptr<Window> owned_window_;
69 68
70 DISALLOW_COPY_AND_ASSIGN(WindowVisibilityObserver); 69 DISALLOW_COPY_AND_ASSIGN(WindowVisibilityObserver);
71 }; 70 };
72 71
73 class TransientWindowManagerTest : public aura::test::AuraTestBase { 72 class TransientWindowManagerTest : public aura::test::AuraTestBase {
74 public: 73 public:
75 TransientWindowManagerTest() {} 74 TransientWindowManagerTest() {}
76 ~TransientWindowManagerTest() override {} 75 ~TransientWindowManagerTest() override {}
77 76
78 void SetUp() override {
79 AuraTestBase::SetUp();
80 wm_state_.reset(new wm::WMState);
81 }
82
83 void TearDown() override {
84 wm_state_.reset();
85 AuraTestBase::TearDown();
86 }
87
88 protected: 77 protected:
89 // Creates a transient window that is transient to |parent|. 78 // Creates a transient window that is transient to |parent|.
90 Window* CreateTransientChild(int id, Window* parent) { 79 Window* CreateTransientChild(int id, Window* parent) {
91 Window* window = new Window(NULL); 80 Window* window = new Window(NULL);
92 window->set_id(id); 81 window->set_id(id);
93 window->SetType(ui::wm::WINDOW_TYPE_NORMAL); 82 window->SetType(ui::wm::WINDOW_TYPE_NORMAL);
94 window->Init(ui::LAYER_TEXTURED); 83 window->Init(ui::LAYER_TEXTURED);
95 AddTransientChild(parent, window); 84 AddTransientChild(parent, window);
96 aura::client::ParentWindowWithContext(window, root_window(), gfx::Rect()); 85 aura::client::ParentWindowWithContext(window, root_window(), gfx::Rect());
97 return window; 86 return window;
98 } 87 }
99 88
100 private: 89 private:
101 std::unique_ptr<wm::WMState> wm_state_;
102
103 DISALLOW_COPY_AND_ASSIGN(TransientWindowManagerTest); 90 DISALLOW_COPY_AND_ASSIGN(TransientWindowManagerTest);
104 }; 91 };
105 92
106 // Various assertions for transient children. 93 // Various assertions for transient children.
107 TEST_F(TransientWindowManagerTest, TransientChildren) { 94 TEST_F(TransientWindowManagerTest, TransientChildren) {
108 std::unique_ptr<Window> parent(CreateTestWindowWithId(0, root_window())); 95 std::unique_ptr<Window> parent(CreateTestWindowWithId(0, root_window()));
109 std::unique_ptr<Window> w1(CreateTestWindowWithId(1, parent.get())); 96 std::unique_ptr<Window> w1(CreateTestWindowWithId(1, parent.get()));
110 std::unique_ptr<Window> w3(CreateTestWindowWithId(3, parent.get())); 97 std::unique_ptr<Window> w3(CreateTestWindowWithId(3, parent.get()));
111 Window* w2 = CreateTestWindowWithId(2, parent.get()); 98 Window* w2 = CreateTestWindowWithId(2, parent.get());
112 // w2 is now owned by w1. 99 // w2 is now owned by w1.
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 EXPECT_EQ(0, test_observer.remove_count()); 442 EXPECT_EQ(0, test_observer.remove_count());
456 443
457 RemoveTransientChild(parent.get(), w1.get()); 444 RemoveTransientChild(parent.get(), w1.get());
458 EXPECT_EQ(1, test_observer.add_count()); 445 EXPECT_EQ(1, test_observer.add_count());
459 EXPECT_EQ(1, test_observer.remove_count()); 446 EXPECT_EQ(1, test_observer.remove_count());
460 447
461 TransientWindowManager::Get(parent.get())->RemoveObserver(&test_observer); 448 TransientWindowManager::Get(parent.get())->RemoveObserver(&test_observer);
462 } 449 }
463 450
464 } // namespace wm 451 } // namespace wm
OLDNEW
« no previous file with comments | « ui/wm/core/transient_window_manager.cc ('k') | ui/wm/core/wm_state.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698