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

Side by Side Diff: athena/wm/window_list_provider_impl_unittest.cc

Issue 662763002: Support modal windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git/+/master
Patch Set: fix leaks Created 6 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 unified diff | Download patch
« no previous file with comments | « athena/wm/split_view_controller_unittest.cc ('k') | athena/wm/window_manager_impl.cc » ('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 "athena/wm/window_list_provider_impl.h" 5 #include "athena/wm/window_list_provider_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "athena/screen/public/screen_manager.h" 9 #include "athena/screen/public/screen_manager.h"
10 #include "athena/test/base/athena_test_base.h" 10 #include "athena/test/base/athena_test_base.h"
11 #include "athena/test/base/test_windows.h"
11 #include "athena/wm/public/window_list_provider_observer.h" 12 #include "athena/wm/public/window_list_provider_observer.h"
12 #include "athena/wm/public/window_manager.h" 13 #include "athena/wm/public/window_manager.h"
13 #include "ui/aura/client/window_tree_client.h" 14 #include "ui/aura/client/window_tree_client.h"
14 #include "ui/aura/test/test_window_delegate.h" 15 #include "ui/aura/test/test_window_delegate.h"
15 #include "ui/aura/window.h" 16 #include "ui/aura/window.h"
16 #include "ui/wm/core/window_util.h" 17 #include "ui/wm/core/window_util.h"
17 18
18 namespace athena { 19 namespace athena {
19 20
20 namespace { 21 namespace {
21 22
22 bool AreWindowListsEqual(const aura::Window::Windows& one, 23 bool AreWindowListsEqual(const aura::Window::Windows& one,
23 const aura::Window::Windows& two) { 24 const aura::Window::Windows& two) {
24 return one.size() == two.size() && 25 return one.size() == two.size() &&
25 std::equal(one.begin(), one.end(), two.begin()); 26 std::equal(one.begin(), one.end(), two.begin());
26 } 27 }
27 28
28 scoped_ptr<aura::Window> CreateWindow(aura::Window* parent, 29 scoped_ptr<aura::Window> CreateWindow(aura::Window* parent,
29 aura::WindowDelegate* delegate, 30 aura::WindowDelegate* delegate,
30 ui::wm::WindowType window_type) { 31 ui::wm::WindowType window_type) {
31 scoped_ptr<aura::Window> window(new aura::Window(delegate)); 32 scoped_ptr<aura::Window> window(new aura::Window(delegate));
32 window->SetType(window_type); 33 window->SetType(window_type);
33 window->Init(aura::WINDOW_LAYER_SOLID_COLOR); 34 window->Init(aura::WINDOW_LAYER_SOLID_COLOR);
34 if (parent) 35 if (parent)
35 parent->AddChild(window.get()); 36 parent->AddChild(window.get());
36 return window.Pass(); 37 return window.Pass();
37 } 38 }
38 39
39 scoped_ptr<aura::Window> CreateTransientWindow(aura::Window* transient_parent,
40 aura::WindowDelegate* delegate,
41 ui::wm::WindowType window_type) {
42 scoped_ptr<aura::Window> window(new aura::Window(delegate));
43 window->SetType(window_type);
44 window->Init(aura::WINDOW_LAYER_SOLID_COLOR);
45 wm::AddTransientChild(transient_parent, window.get());
46 aura::client::ParentWindowWithContext(
47 window.get(), ScreenManager::Get()->GetContext(), gfx::Rect());
48 return window.Pass();
49 }
50
51 // Return a string which defines the order of windows in |now| using the indices 40 // Return a string which defines the order of windows in |now| using the indices
52 // of |original|. The string will then have the lowest/oldest window on the left 41 // of |original|. The string will then have the lowest/oldest window on the left
53 // and the highest / newest on the right. 42 // and the highest / newest on the right.
54 std::string GetWindowOrder(const aura::Window::Windows& original, 43 std::string GetWindowOrder(const aura::Window::Windows& original,
55 const aura::Window::Windows& now) { 44 const aura::Window::Windows& now) {
56 if (original.size() != now.size()) 45 if (original.size() != now.size())
57 return "size has changed."; 46 return "size has changed.";
58 std::string output; 47 std::string output;
59 for (aura::Window::Windows::const_iterator it = now.begin(); 48 for (aura::Window::Windows::const_iterator it = now.begin();
60 it != now.end(); ++it) { 49 it != now.end(); ++it) {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 typedef test::AthenaTestBase WindowListProviderImplTest; 98 typedef test::AthenaTestBase WindowListProviderImplTest;
110 99
111 // Tests that the order of windows match the stacking order of the windows in 100 // Tests that the order of windows match the stacking order of the windows in
112 // the container, even after the order is changed through the aura Window API. 101 // the container, even after the order is changed through the aura Window API.
113 TEST_F(WindowListProviderImplTest, StackingOrder) { 102 TEST_F(WindowListProviderImplTest, StackingOrder) {
114 aura::test::TestWindowDelegate delegate; 103 aura::test::TestWindowDelegate delegate;
115 scoped_ptr<aura::Window> container(new aura::Window(&delegate)); 104 scoped_ptr<aura::Window> container(new aura::Window(&delegate));
116 scoped_ptr<WindowListProvider> list_provider( 105 scoped_ptr<WindowListProvider> list_provider(
117 new WindowListProviderImpl(container.get())); 106 new WindowListProviderImpl(container.get()));
118 107
119 scoped_ptr<aura::Window> first = 108 scoped_ptr<aura::Window> first = test::CreateWindowWithType(
120 CreateWindow(container.get(), &delegate, ui::wm::WINDOW_TYPE_NORMAL); 109 &delegate, container.get(), ui::wm::WINDOW_TYPE_NORMAL);
121 scoped_ptr<aura::Window> second = 110 scoped_ptr<aura::Window> second =
122 CreateWindow(container.get(), &delegate, ui::wm::WINDOW_TYPE_NORMAL); 111 CreateWindow(container.get(), &delegate, ui::wm::WINDOW_TYPE_NORMAL);
123 scoped_ptr<aura::Window> third = 112 scoped_ptr<aura::Window> third =
124 CreateWindow(container.get(), &delegate, ui::wm::WINDOW_TYPE_NORMAL); 113 CreateWindow(container.get(), &delegate, ui::wm::WINDOW_TYPE_NORMAL);
125 114
126 EXPECT_EQ(3u, container->children().size()); 115 EXPECT_EQ(3u, container->children().size());
127 EXPECT_EQ(container->children().size(), 116 EXPECT_EQ(container->children().size(),
128 list_provider->GetWindowList().size()); 117 list_provider->GetWindowList().size());
129 118
130 EXPECT_TRUE(AreWindowListsEqual(container->children(), 119 EXPECT_TRUE(AreWindowListsEqual(container->children(),
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 // Test that transient windows are handled property. 289 // Test that transient windows are handled property.
301 TEST_F(WindowListProviderImplTest, TransientWindows) { 290 TEST_F(WindowListProviderImplTest, TransientWindows) {
302 aura::test::TestWindowDelegate delegate; 291 aura::test::TestWindowDelegate delegate;
303 delegate.set_can_focus(true); 292 delegate.set_can_focus(true);
304 293
305 WindowListProvider* list_provider = 294 WindowListProvider* list_provider =
306 WindowManager::Get()->GetWindowListProvider(); 295 WindowManager::Get()->GetWindowListProvider();
307 296
308 scoped_ptr<WindowListObserver> observer( 297 scoped_ptr<WindowListObserver> observer(
309 new WindowListObserver(list_provider)); 298 new WindowListObserver(list_provider));
310 scoped_ptr<aura::Window> w1 = CreateTestWindow(&delegate, gfx::Rect()); 299 scoped_ptr<aura::Window> w1 = test::CreateNormalWindow(&delegate, NULL);
311 w1->Show(); 300 w1->Show();
312 scoped_ptr<aura::Window> w2 = CreateTestWindow(&delegate, gfx::Rect()); 301 scoped_ptr<aura::Window> w2 = test::CreateNormalWindow(&delegate, NULL);
313 w2->Show(); 302 w2->Show();
314 scoped_ptr<aura::Window> t1 = 303 scoped_ptr<aura::Window> t1 = test::CreateTransientWindow(
315 CreateTransientWindow(w1.get(), &delegate, ui::wm::WINDOW_TYPE_NORMAL); 304 &delegate, w1.get(), ui::MODAL_TYPE_NONE, false);
316 t1->Show(); 305 t1->Show();
317 306
318 EXPECT_EQ(2u, list_provider->GetWindowList().size()); 307 EXPECT_EQ(2u, list_provider->GetWindowList().size());
319 308
320 // Activation should honor transient relations. 309 // Activation should honor transient relations.
321 wm::ActivateWindow(w2.get()); 310 wm::ActivateWindow(w2.get());
322 EXPECT_EQ(w1.get(), list_provider->GetWindowList()[0]); 311 EXPECT_EQ(w1.get(), list_provider->GetWindowList()[0]);
323 EXPECT_EQ(w2.get(), list_provider->GetWindowList()[1]); 312 EXPECT_EQ(w2.get(), list_provider->GetWindowList()[1]);
324 313
325 EXPECT_EQ(w1.get(), w1->parent()->children()[0]); 314 EXPECT_EQ(w1.get(), w1->parent()->children()[0]);
(...skipping 24 matching lines...) Expand all
350 EXPECT_FALSE(t1->IsVisible()); 339 EXPECT_FALSE(t1->IsVisible());
351 w1->Show(); 340 w1->Show();
352 EXPECT_TRUE(t1->IsVisible()); 341 EXPECT_TRUE(t1->IsVisible());
353 342
354 // Resetting transient window won't notify the observer. 343 // Resetting transient window won't notify the observer.
355 t1.reset(); 344 t1.reset();
356 EXPECT_EQ(0, observer->window_removal_calls()); 345 EXPECT_EQ(0, observer->window_removal_calls());
357 } 346 }
358 347
359 } // namespace athena 348 } // namespace athena
OLDNEW
« no previous file with comments | « athena/wm/split_view_controller_unittest.cc ('k') | athena/wm/window_manager_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698