Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "ash/wm/ash_activation_controller.h" | |
| 6 | |
| 7 #include "ash/launcher/launcher.h" | |
| 8 #include "ash/root_window_controller.h" | |
| 9 #include "ash/shell_delegate.h" | |
| 10 #include "ash/test/ash_test_base.h" | |
| 11 #include "ash/wm/property_util.h" | |
| 12 #include "ui/aura/window.h" | |
| 13 | |
| 14 namespace ash { | |
| 15 | |
| 16 namespace { | |
| 17 | |
| 18 class AshActivationControllerTest : public test::AshTestBase { | |
| 19 public: | |
| 20 AshActivationControllerTest() {} | |
| 21 virtual ~AshActivationControllerTest() {} | |
| 22 | |
| 23 virtual void SetUp() OVERRIDE { | |
| 24 test::AshTestBase::SetUp(); | |
| 25 ash_activation_controller_.reset(new internal::AshActivationController()); | |
| 26 launcher_ = Launcher::ForPrimaryDisplay(); | |
| 27 launcher_widget_ = launcher_->widget(); | |
| 28 launcher_window_ = | |
|
sky
2012/12/10 15:37:51
launcher_window_ = launcher_widget_->GetNativeWind
mtomasz
2012/12/11 05:03:32
Done.
| |
| 29 Launcher::ForPrimaryDisplay()->widget()->GetNativeWindow(); | |
| 30 DCHECK(launcher_ != NULL); | |
|
sky
2012/12/10 15:37:51
DCHECK->ASSERT_TRUE Also, this should be between 2
mtomasz
2012/12/11 05:03:32
Done.
| |
| 31 DCHECK(launcher_widget_ != NULL); | |
| 32 DCHECK(launcher_window_ != NULL); | |
| 33 } | |
| 34 | |
| 35 void SetSpokenFeedbackState(bool enabled) { | |
| 36 if (Shell::GetInstance()->delegate()->IsSpokenFeedbackEnabled() != | |
| 37 enabled) { | |
| 38 Shell::GetInstance()->delegate()->ToggleSpokenFeedback(); | |
| 39 } | |
| 40 } | |
| 41 | |
| 42 protected: | |
| 43 scoped_ptr<internal::ActivationControllerDelegate> ash_activation_controller_; | |
| 44 ash::Launcher* launcher_; | |
|
sky
2012/12/10 15:37:51
Member initialize these to NULL.
mtomasz
2012/12/11 05:03:32
Done.
| |
| 45 views::Widget* launcher_widget_; | |
| 46 aura::Window* launcher_window_; | |
| 47 | |
| 48 DISALLOW_COPY_AND_ASSIGN(AshActivationControllerTest); | |
| 49 }; | |
| 50 | |
| 51 TEST_F(AshActivationControllerTest, LauncherFallback) { | |
| 52 // When spoken feedback is disabled, then fallback should not occur. | |
| 53 { | |
| 54 SetSpokenFeedbackState(false); | |
| 55 aura::Window* result = ash_activation_controller_->WillActivateWindow(NULL); | |
|
sky
2012/12/10 15:37:51
Rather than explicitly calling through like this c
mtomasz
2012/12/11 05:03:32
I could, but would it be better? We would loose is
sky
2012/12/11 16:30:47
I'm for testing actual window activation since in
mtomasz
2012/12/13 07:55:29
My concern is that I don't think we want AshActiva
sky
2012/12/13 19:16:27
Exactly.
mtomasz
2012/12/14 05:31:42
Done.
| |
| 56 EXPECT_EQ(NULL, result); | |
| 57 } | |
| 58 | |
| 59 // When spoken feedback is enabled, then fallback should occur. | |
| 60 { | |
| 61 SetSpokenFeedbackState(true); | |
| 62 aura::Window* result = ash_activation_controller_->WillActivateWindow(NULL); | |
| 63 EXPECT_EQ(launcher_window_, result); | |
| 64 } | |
| 65 | |
| 66 // No fallback when activating another window. | |
| 67 { | |
| 68 aura::Window* test_window = CreateTestWindowInShellWithId(0); | |
| 69 aura::Window* result = ash_activation_controller_-> | |
| 70 WillActivateWindow(test_window); | |
| 71 EXPECT_EQ(test_window, result); | |
| 72 } | |
| 73 } | |
| 74 | |
| 75 TEST_F(AshActivationControllerTest, LauncherFallbackOnShutdown) { | |
| 76 SetSpokenFeedbackState(true); | |
| 77 // While shutting down a root window controller, activation controller | |
| 78 // is notified about destroyed windows and therefore will try to activate | |
| 79 // a launcher as fallback, which would result in segmentation faults since | |
| 80 // the launcher's window or the workspace's controller may be already | |
| 81 // destroyed. | |
| 82 GetRootWindowController(Shell::GetActiveRootWindow())->CloseChildWindows(); | |
| 83 | |
| 84 aura::Window* result = ash_activation_controller_->WillActivateWindow(NULL); | |
| 85 EXPECT_EQ(NULL, result); | |
| 86 } | |
| 87 | |
| 88 } // namespace | |
| 89 | |
| 90 } // namespace ash | |
| OLD | NEW |