| OLD | NEW |
| 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" |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 } | 150 } |
| 151 | 151 |
| 152 // Testing that IsValidWidow, IsWindowInList and AddWindow work as expected. | 152 // Testing that IsValidWidow, IsWindowInList and AddWindow work as expected. |
| 153 TEST_F(WindowListProviderImplTest, SimpleChecks) { | 153 TEST_F(WindowListProviderImplTest, SimpleChecks) { |
| 154 aura::test::TestWindowDelegate delegate; | 154 aura::test::TestWindowDelegate delegate; |
| 155 scoped_ptr<aura::Window> container(new aura::Window(&delegate)); | 155 scoped_ptr<aura::Window> container(new aura::Window(&delegate)); |
| 156 scoped_ptr<WindowListProviderImpl> list_provider( | 156 scoped_ptr<WindowListProviderImpl> list_provider( |
| 157 new WindowListProviderImpl(container.get())); | 157 new WindowListProviderImpl(container.get())); |
| 158 | 158 |
| 159 scoped_ptr<aura::Window> normal_window = | 159 scoped_ptr<aura::Window> normal_window = |
| 160 CreateWindow(NULL, &delegate, ui::wm::WINDOW_TYPE_NORMAL); | 160 CreateWindow(nullptr, &delegate, ui::wm::WINDOW_TYPE_NORMAL); |
| 161 scoped_ptr<aura::Window> popup_window = | 161 scoped_ptr<aura::Window> popup_window = |
| 162 CreateWindow(NULL, &delegate, ui::wm::WINDOW_TYPE_POPUP); | 162 CreateWindow(nullptr, &delegate, ui::wm::WINDOW_TYPE_POPUP); |
| 163 scoped_ptr<aura::Window> menu_window = | 163 scoped_ptr<aura::Window> menu_window = |
| 164 CreateWindow(NULL, &delegate, ui::wm::WINDOW_TYPE_MENU); | 164 CreateWindow(nullptr, &delegate, ui::wm::WINDOW_TYPE_MENU); |
| 165 | 165 |
| 166 // Check which windows are valid and which are not. | 166 // Check which windows are valid and which are not. |
| 167 EXPECT_TRUE(list_provider->IsValidWindow(normal_window.get())); | 167 EXPECT_TRUE(list_provider->IsValidWindow(normal_window.get())); |
| 168 EXPECT_FALSE(list_provider->IsValidWindow(popup_window.get())); | 168 EXPECT_FALSE(list_provider->IsValidWindow(popup_window.get())); |
| 169 EXPECT_FALSE(list_provider->IsValidWindow(menu_window.get())); | 169 EXPECT_FALSE(list_provider->IsValidWindow(menu_window.get())); |
| 170 | 170 |
| 171 // Check that no window is currently in the list. | 171 // Check that no window is currently in the list. |
| 172 EXPECT_FALSE(list_provider->IsWindowInList(normal_window.get())); | 172 EXPECT_FALSE(list_provider->IsWindowInList(normal_window.get())); |
| 173 EXPECT_FALSE(list_provider->IsWindowInList(popup_window.get())); | 173 EXPECT_FALSE(list_provider->IsWindowInList(popup_window.get())); |
| 174 EXPECT_FALSE(list_provider->IsWindowInList(menu_window.get())); | 174 EXPECT_FALSE(list_provider->IsWindowInList(menu_window.get())); |
| 175 | 175 |
| 176 // Check that adding the window will add it to the list. | 176 // Check that adding the window will add it to the list. |
| 177 container->AddChild(normal_window.get()); | 177 container->AddChild(normal_window.get()); |
| 178 EXPECT_TRUE(list_provider->IsWindowInList(normal_window.get())); | 178 EXPECT_TRUE(list_provider->IsWindowInList(normal_window.get())); |
| 179 } | 179 } |
| 180 | 180 |
| 181 // Testing that window ordering functions work as expected. | 181 // Testing that window ordering functions work as expected. |
| 182 TEST_F(WindowListProviderImplTest, TestWindowOrderingFunctions) { | 182 TEST_F(WindowListProviderImplTest, TestWindowOrderingFunctions) { |
| 183 aura::test::TestWindowDelegate delegate; | 183 aura::test::TestWindowDelegate delegate; |
| 184 scoped_ptr<aura::Window> container(new aura::Window(&delegate)); | 184 scoped_ptr<aura::Window> container(new aura::Window(&delegate)); |
| 185 scoped_ptr<WindowListProvider> list_provider( | 185 scoped_ptr<WindowListProvider> list_provider( |
| 186 new WindowListProviderImpl(container.get())); | 186 new WindowListProviderImpl(container.get())); |
| 187 scoped_ptr<WindowListObserver> observer( | 187 scoped_ptr<WindowListObserver> observer( |
| 188 new WindowListObserver(list_provider.get())); | 188 new WindowListObserver(list_provider.get())); |
| 189 | 189 |
| 190 scoped_ptr<aura::Window> window1 = | 190 scoped_ptr<aura::Window> window1 = |
| 191 CreateWindow(NULL, &delegate, ui::wm::WINDOW_TYPE_NORMAL); | 191 CreateWindow(nullptr, &delegate, ui::wm::WINDOW_TYPE_NORMAL); |
| 192 scoped_ptr<aura::Window> window2 = | 192 scoped_ptr<aura::Window> window2 = |
| 193 CreateWindow(NULL, &delegate, ui::wm::WINDOW_TYPE_NORMAL); | 193 CreateWindow(nullptr, &delegate, ui::wm::WINDOW_TYPE_NORMAL); |
| 194 scoped_ptr<aura::Window> window3 = | 194 scoped_ptr<aura::Window> window3 = |
| 195 CreateWindow(NULL, &delegate, ui::wm::WINDOW_TYPE_NORMAL); | 195 CreateWindow(nullptr, &delegate, ui::wm::WINDOW_TYPE_NORMAL); |
| 196 | 196 |
| 197 EXPECT_FALSE(list_provider->IsWindowInList(window1.get())); | 197 EXPECT_FALSE(list_provider->IsWindowInList(window1.get())); |
| 198 EXPECT_FALSE(list_provider->IsWindowInList(window2.get())); | 198 EXPECT_FALSE(list_provider->IsWindowInList(window2.get())); |
| 199 EXPECT_FALSE(list_provider->IsWindowInList(window3.get())); | 199 EXPECT_FALSE(list_provider->IsWindowInList(window3.get())); |
| 200 | 200 |
| 201 // Add the windows. | 201 // Add the windows. |
| 202 container->AddChild(window1.get()); | 202 container->AddChild(window1.get()); |
| 203 container->AddChild(window2.get()); | 203 container->AddChild(window2.get()); |
| 204 container->AddChild(window3.get()); | 204 container->AddChild(window3.get()); |
| 205 // Make a copy of the window-list in the original order. | 205 // Make a copy of the window-list in the original order. |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 // Test that transient windows are handled property. | 289 // Test that transient windows are handled property. |
| 290 TEST_F(WindowListProviderImplTest, TransientWindows) { | 290 TEST_F(WindowListProviderImplTest, TransientWindows) { |
| 291 aura::test::TestWindowDelegate delegate; | 291 aura::test::TestWindowDelegate delegate; |
| 292 delegate.set_can_focus(true); | 292 delegate.set_can_focus(true); |
| 293 | 293 |
| 294 WindowListProvider* list_provider = | 294 WindowListProvider* list_provider = |
| 295 WindowManager::Get()->GetWindowListProvider(); | 295 WindowManager::Get()->GetWindowListProvider(); |
| 296 | 296 |
| 297 scoped_ptr<WindowListObserver> observer( | 297 scoped_ptr<WindowListObserver> observer( |
| 298 new WindowListObserver(list_provider)); | 298 new WindowListObserver(list_provider)); |
| 299 scoped_ptr<aura::Window> w1 = test::CreateNormalWindow(&delegate, NULL); | 299 scoped_ptr<aura::Window> w1 = test::CreateNormalWindow(&delegate, nullptr); |
| 300 w1->Show(); | 300 w1->Show(); |
| 301 scoped_ptr<aura::Window> w2 = test::CreateNormalWindow(&delegate, NULL); | 301 scoped_ptr<aura::Window> w2 = test::CreateNormalWindow(&delegate, nullptr); |
| 302 w2->Show(); | 302 w2->Show(); |
| 303 scoped_ptr<aura::Window> t1 = test::CreateTransientWindow( | 303 scoped_ptr<aura::Window> t1 = test::CreateTransientWindow( |
| 304 &delegate, w1.get(), ui::MODAL_TYPE_NONE, false); | 304 &delegate, w1.get(), ui::MODAL_TYPE_NONE, false); |
| 305 t1->Show(); | 305 t1->Show(); |
| 306 | 306 |
| 307 EXPECT_EQ(2u, list_provider->GetWindowList().size()); | 307 EXPECT_EQ(2u, list_provider->GetWindowList().size()); |
| 308 | 308 |
| 309 // Activation should honor transient relations. | 309 // Activation should honor transient relations. |
| 310 wm::ActivateWindow(w2.get()); | 310 wm::ActivateWindow(w2.get()); |
| 311 EXPECT_EQ(w1.get(), list_provider->GetWindowList()[0]); | 311 EXPECT_EQ(w1.get(), list_provider->GetWindowList()[0]); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 339 EXPECT_FALSE(t1->IsVisible()); | 339 EXPECT_FALSE(t1->IsVisible()); |
| 340 w1->Show(); | 340 w1->Show(); |
| 341 EXPECT_TRUE(t1->IsVisible()); | 341 EXPECT_TRUE(t1->IsVisible()); |
| 342 | 342 |
| 343 // Resetting transient window won't notify the observer. | 343 // Resetting transient window won't notify the observer. |
| 344 t1.reset(); | 344 t1.reset(); |
| 345 EXPECT_EQ(0, observer->window_removal_calls()); | 345 EXPECT_EQ(0, observer->window_removal_calls()); |
| 346 } | 346 } |
| 347 | 347 |
| 348 } // namespace athena | 348 } // namespace athena |
| OLD | NEW |