OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ash/shell.h" | 5 #include "ash/shell.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "ash/ash_switches.h" | 10 #include "ash/ash_switches.h" |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 std::vector<aura::Window*> results; | 345 std::vector<aura::Window*> results; |
346 while (window) { | 346 while (window) { |
347 results.push_back(window); | 347 results.push_back(window); |
348 window = window->parent(); | 348 window = window->parent(); |
349 } | 349 } |
350 return results; | 350 return results; |
351 } | 351 } |
352 | 352 |
353 } // namespace | 353 } // namespace |
354 | 354 |
355 // Various assertions around IsAutoHideMenuHideChecked() and | 355 // Various assertions around SetShelfAutoHideBehavior() and |
356 // ToggleAutoHideMenu(). | 356 // GetShelfAutoHideBehavior(). |
357 TEST_F(ShellTest, ToggleAutoHide) { | 357 TEST_F(ShellTest, ToggleAutoHide) { |
358 scoped_ptr<aura::Window> window(new aura::Window(NULL)); | 358 scoped_ptr<aura::Window> window(new aura::Window(NULL)); |
359 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); | 359 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); |
360 window->SetType(aura::client::WINDOW_TYPE_NORMAL); | 360 window->SetType(aura::client::WINDOW_TYPE_NORMAL); |
361 window->Init(ui::LAYER_TEXTURED); | 361 window->Init(ui::LAYER_TEXTURED); |
362 window->SetParent(NULL); | 362 window->SetParent(NULL); |
363 window->Show(); | 363 window->Show(); |
364 wm::ActivateWindow(window.get()); | 364 wm::ActivateWindow(window.get()); |
365 | 365 |
366 internal::RootWindowController* controller = | 366 Shell* shell = Shell::GetInstance(); |
367 Shell::GetPrimaryRootWindowController(); | 367 aura::RootWindow* root_window = Shell::GetPrimaryRootWindow(); |
368 controller->SetShelfAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 368 shell->SetShelfAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, |
| 369 root_window); |
369 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, | 370 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, |
370 controller->GetShelfAutoHideBehavior()); | 371 shell->GetShelfAutoHideBehavior(root_window)); |
371 EXPECT_TRUE(controller->IsShelfAutoHideMenuHideChecked()); | 372 shell->SetShelfAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER, |
372 controller->SetShelfAutoHideBehavior( | 373 root_window); |
373 controller->GetToggledShelfAutoHideBehavior()); | |
374 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER, | 374 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER, |
375 controller->GetShelfAutoHideBehavior()); | 375 shell->GetShelfAutoHideBehavior(root_window)); |
376 | |
377 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 376 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
378 EXPECT_FALSE(controller->IsShelfAutoHideMenuHideChecked()); | 377 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER, |
379 controller->SetShelfAutoHideBehavior( | 378 shell->GetShelfAutoHideBehavior(root_window)); |
380 controller->GetToggledShelfAutoHideBehavior()); | 379 shell->SetShelfAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, |
| 380 root_window); |
381 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, | 381 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, |
382 controller->GetShelfAutoHideBehavior()); | 382 shell->GetShelfAutoHideBehavior(root_window)); |
383 EXPECT_TRUE(controller->IsShelfAutoHideMenuHideChecked()); | 383 shell->SetShelfAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER, |
384 controller->SetShelfAutoHideBehavior( | 384 root_window); |
385 controller->GetToggledShelfAutoHideBehavior()); | |
386 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER, | 385 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER, |
387 controller->GetShelfAutoHideBehavior()); | 386 shell->GetShelfAutoHideBehavior(root_window)); |
388 } | 387 } |
389 | 388 |
390 // This verifies WindowObservers are removed when a window is destroyed after | 389 // This verifies WindowObservers are removed when a window is destroyed after |
391 // the Shell is destroyed. This scenario (aura::Windows being deleted after the | 390 // the Shell is destroyed. This scenario (aura::Windows being deleted after the |
392 // Shell) occurs if someone is holding a reference to an unparented Window, as | 391 // Shell) occurs if someone is holding a reference to an unparented Window, as |
393 // is the case with a RenderWidgetHostViewAura that isn't on screen. As long as | 392 // is the case with a RenderWidgetHostViewAura that isn't on screen. As long as |
394 // everything is ok, we won't crash. If there is a bug, window's destructor will | 393 // everything is ok, we won't crash. If there is a bug, window's destructor will |
395 // notify some deleted object (say VideoDetector or ActivationController) and | 394 // notify some deleted object (say VideoDetector or ActivationController) and |
396 // this will crash. | 395 // this will crash. |
397 class ShellTest2 : public test::AshTestBase { | 396 class ShellTest2 : public test::AshTestBase { |
398 public: | 397 public: |
399 ShellTest2() {} | 398 ShellTest2() {} |
400 virtual ~ShellTest2() {} | 399 virtual ~ShellTest2() {} |
401 | 400 |
402 protected: | 401 protected: |
403 scoped_ptr<aura::Window> window_; | 402 scoped_ptr<aura::Window> window_; |
404 | 403 |
405 private: | 404 private: |
406 DISALLOW_COPY_AND_ASSIGN(ShellTest2); | 405 DISALLOW_COPY_AND_ASSIGN(ShellTest2); |
407 }; | 406 }; |
408 | 407 |
409 TEST_F(ShellTest2, DontCrashWhenWindowDeleted) { | 408 TEST_F(ShellTest2, DontCrashWhenWindowDeleted) { |
410 window_.reset(new aura::Window(NULL)); | 409 window_.reset(new aura::Window(NULL)); |
411 window_->Init(ui::LAYER_NOT_DRAWN); | 410 window_->Init(ui::LAYER_NOT_DRAWN); |
412 } | 411 } |
413 | 412 |
414 } // namespace ash | 413 } // namespace ash |
OLD | NEW |