| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/test/ash_test_helper.h" | 5 #include "ash/test/ash_test_helper.h" |
| 6 | 6 |
| 7 #include "base/at_exit.h" |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 8 #include "ui/aura/window_event_dispatcher.h" | 9 #include "ui/aura/window_event_dispatcher.h" |
| 9 #include "ui/views/widget/widget.h" | 10 #include "ui/views/widget/widget.h" |
| 10 | 11 |
| 11 #if defined(OS_WIN) | 12 #if defined(OS_WIN) |
| 12 #include "base/win/windows_version.h" | 13 #include "base/win/windows_version.h" |
| 13 #endif | 14 #endif |
| 14 | 15 |
| 15 // Tests for AshTestHelper. Who will watch the watchers? And who will test | 16 // Tests for AshTestHelper. Who will watch the watchers? And who will test |
| 16 // the tests? | 17 // the tests? |
| (...skipping 11 matching lines...) Expand all Loading... |
| 28 virtual void TearDown() OVERRIDE { | 29 virtual void TearDown() OVERRIDE { |
| 29 ash_test_helper_->TearDown(); | 30 ash_test_helper_->TearDown(); |
| 30 testing::Test::TearDown(); | 31 testing::Test::TearDown(); |
| 31 } | 32 } |
| 32 | 33 |
| 33 ash::test::AshTestHelper* ash_test_helper() { | 34 ash::test::AshTestHelper* ash_test_helper() { |
| 34 return ash_test_helper_.get(); | 35 return ash_test_helper_.get(); |
| 35 } | 36 } |
| 36 | 37 |
| 37 private: | 38 private: |
| 39 base::ShadowingAtExitManager at_exit_; |
| 38 base::MessageLoopForUI message_loop_; | 40 base::MessageLoopForUI message_loop_; |
| 39 scoped_ptr<ash::test::AshTestHelper> ash_test_helper_; | 41 scoped_ptr<ash::test::AshTestHelper> ash_test_helper_; |
| 40 | 42 |
| 41 DISALLOW_COPY_AND_ASSIGN(AshTestHelperTest); | 43 DISALLOW_COPY_AND_ASSIGN(AshTestHelperTest); |
| 42 }; | 44 }; |
| 43 | 45 |
| 44 // Ensure that we have initialized enough of Ash to create and show a window. | 46 // Ensure that we have initialized enough of Ash to create and show a window. |
| 45 TEST_F(AshTestHelperTest, AshTestHelper) { | 47 TEST_F(AshTestHelperTest, AshTestHelper) { |
| 46 // Check initial state. | 48 // Check initial state. |
| 47 EXPECT_TRUE(ash_test_helper()->message_loop()); | 49 EXPECT_TRUE(ash_test_helper()->message_loop()); |
| 48 EXPECT_TRUE(ash_test_helper()->test_shell_delegate()); | 50 EXPECT_TRUE(ash_test_helper()->test_shell_delegate()); |
| 49 EXPECT_TRUE(ash_test_helper()->CurrentContext()); | 51 EXPECT_TRUE(ash_test_helper()->CurrentContext()); |
| 50 | 52 |
| 51 // Enough state is initialized to create a window. | 53 // Enough state is initialized to create a window. |
| 52 using views::Widget; | 54 using views::Widget; |
| 53 scoped_ptr<Widget> w1(new Widget); | 55 scoped_ptr<Widget> w1(new Widget); |
| 54 Widget::InitParams params; | 56 Widget::InitParams params; |
| 55 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 57 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 56 params.context = ash_test_helper()->CurrentContext(); | 58 params.context = ash_test_helper()->CurrentContext(); |
| 57 w1->Init(params); | 59 w1->Init(params); |
| 58 w1->Show(); | 60 w1->Show(); |
| 59 EXPECT_TRUE(w1->IsActive()); | 61 EXPECT_TRUE(w1->IsActive()); |
| 60 EXPECT_TRUE(w1->IsVisible()); | 62 EXPECT_TRUE(w1->IsVisible()); |
| 61 } | 63 } |
| OLD | NEW |