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

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

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