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 "ash/test/ash_test_environment.h" | |
8 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
9 #include "ui/aura/window_event_dispatcher.h" | 8 #include "ui/aura/window_event_dispatcher.h" |
10 #include "ui/views/widget/widget.h" | 9 #include "ui/views/widget/widget.h" |
11 | 10 |
12 namespace ash { | 11 #if defined(OS_WIN) |
| 12 #include "base/win/windows_version.h" |
| 13 #endif |
13 | 14 |
14 // Tests for AshTestHelper. Who will watch the watchers? And who will test | 15 // Tests for AshTestHelper. Who will watch the watchers? And who will test |
15 // the tests? | 16 // the tests? |
16 class AshTestHelperTest : public testing::Test { | 17 class AshTestHelperTest : public testing::Test { |
17 public: | 18 public: |
18 AshTestHelperTest() {} | 19 AshTestHelperTest() {} |
19 ~AshTestHelperTest() override {} | 20 ~AshTestHelperTest() override {} |
20 | 21 |
21 void SetUp() override { | 22 void SetUp() override { |
22 testing::Test::SetUp(); | 23 testing::Test::SetUp(); |
23 ash_test_environment_ = test::AshTestEnvironment::Create(); | 24 ash_test_helper_.reset(new ash::test::AshTestHelper(&message_loop_)); |
24 ash_test_helper_.reset( | |
25 new test::AshTestHelper(ash_test_environment_.get())); | |
26 ash_test_helper_->SetUp(true, | 25 ash_test_helper_->SetUp(true, |
27 MaterialDesignController::Mode::UNINITIALIZED); | 26 ash::MaterialDesignController::Mode::UNINITIALIZED); |
28 } | 27 } |
29 | 28 |
30 void TearDown() override { | 29 void TearDown() override { |
31 ash_test_helper_->TearDown(); | 30 ash_test_helper_->TearDown(); |
32 testing::Test::TearDown(); | 31 testing::Test::TearDown(); |
33 } | 32 } |
34 | 33 |
35 test::AshTestHelper* ash_test_helper() { return ash_test_helper_.get(); } | 34 ash::test::AshTestHelper* ash_test_helper() { return ash_test_helper_.get(); } |
36 | |
37 protected: | |
38 std::unique_ptr<test::AshTestEnvironment> ash_test_environment_; | |
39 | 35 |
40 private: | 36 private: |
41 std::unique_ptr<test::AshTestHelper> ash_test_helper_; | 37 base::MessageLoopForUI message_loop_; |
| 38 std::unique_ptr<ash::test::AshTestHelper> ash_test_helper_; |
42 | 39 |
43 DISALLOW_COPY_AND_ASSIGN(AshTestHelperTest); | 40 DISALLOW_COPY_AND_ASSIGN(AshTestHelperTest); |
44 }; | 41 }; |
45 | 42 |
46 // Ensure that we have initialized enough of Ash to create and show a window. | 43 // Ensure that we have initialized enough of Ash to create and show a window. |
47 TEST_F(AshTestHelperTest, AshTestHelper) { | 44 TEST_F(AshTestHelperTest, AshTestHelper) { |
48 // Check initial state. | 45 // Check initial state. |
| 46 EXPECT_TRUE(ash_test_helper()->message_loop()); |
49 EXPECT_TRUE(ash_test_helper()->test_shell_delegate()); | 47 EXPECT_TRUE(ash_test_helper()->test_shell_delegate()); |
50 EXPECT_TRUE(ash_test_helper()->CurrentContext()); | 48 EXPECT_TRUE(ash_test_helper()->CurrentContext()); |
51 | 49 |
52 // Enough state is initialized to create a window. | 50 // Enough state is initialized to create a window. |
53 using views::Widget; | 51 using views::Widget; |
54 std::unique_ptr<Widget> w1(new Widget); | 52 std::unique_ptr<Widget> w1(new Widget); |
55 Widget::InitParams params; | 53 Widget::InitParams params; |
56 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 54 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
57 params.context = ash_test_helper()->CurrentContext(); | 55 params.context = ash_test_helper()->CurrentContext(); |
58 w1->Init(params); | 56 w1->Init(params); |
59 w1->Show(); | 57 w1->Show(); |
60 EXPECT_TRUE(w1->IsActive()); | 58 EXPECT_TRUE(w1->IsActive()); |
61 EXPECT_TRUE(w1->IsVisible()); | 59 EXPECT_TRUE(w1->IsVisible()); |
62 } | 60 } |
63 | |
64 } // namespace ash | |
OLD | NEW |