| 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 "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 #include "ui/aura/window_event_dispatcher.h" | 8 #include "ui/aura/window_event_dispatcher.h" |
| 9 #include "ui/views/widget/widget.h" | 9 #include "ui/views/widget/widget.h" |
| 10 | 10 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 testing::Test::SetUp(); | 23 testing::Test::SetUp(); |
| 24 ash_test_helper_.reset(new ash::test::AshTestHelper(&message_loop_)); | 24 ash_test_helper_.reset(new ash::test::AshTestHelper(&message_loop_)); |
| 25 ash_test_helper_->SetUp(true); | 25 ash_test_helper_->SetUp(true); |
| 26 } | 26 } |
| 27 | 27 |
| 28 void TearDown() override { | 28 void TearDown() override { |
| 29 ash_test_helper_->TearDown(); | 29 ash_test_helper_->TearDown(); |
| 30 testing::Test::TearDown(); | 30 testing::Test::TearDown(); |
| 31 } | 31 } |
| 32 | 32 |
| 33 ash::test::AshTestHelper* ash_test_helper() { | 33 ash::test::AshTestHelper* ash_test_helper() { return ash_test_helper_.get(); } |
| 34 return ash_test_helper_.get(); | |
| 35 } | |
| 36 | 34 |
| 37 private: | 35 private: |
| 38 base::MessageLoopForUI message_loop_; | 36 base::MessageLoopForUI message_loop_; |
| 39 std::unique_ptr<ash::test::AshTestHelper> ash_test_helper_; | 37 std::unique_ptr<ash::test::AshTestHelper> ash_test_helper_; |
| 40 | 38 |
| 41 DISALLOW_COPY_AND_ASSIGN(AshTestHelperTest); | 39 DISALLOW_COPY_AND_ASSIGN(AshTestHelperTest); |
| 42 }; | 40 }; |
| 43 | 41 |
| 44 // Ensure that we have initialized enough of Ash to create and show a window. | 42 // Ensure that we have initialized enough of Ash to create and show a window. |
| 45 TEST_F(AshTestHelperTest, AshTestHelper) { | 43 TEST_F(AshTestHelperTest, AshTestHelper) { |
| 46 // Check initial state. | 44 // Check initial state. |
| 47 EXPECT_TRUE(ash_test_helper()->message_loop()); | 45 EXPECT_TRUE(ash_test_helper()->message_loop()); |
| 48 EXPECT_TRUE(ash_test_helper()->test_shell_delegate()); | 46 EXPECT_TRUE(ash_test_helper()->test_shell_delegate()); |
| 49 EXPECT_TRUE(ash_test_helper()->CurrentContext()); | 47 EXPECT_TRUE(ash_test_helper()->CurrentContext()); |
| 50 | 48 |
| 51 // Enough state is initialized to create a window. | 49 // Enough state is initialized to create a window. |
| 52 using views::Widget; | 50 using views::Widget; |
| 53 std::unique_ptr<Widget> w1(new Widget); | 51 std::unique_ptr<Widget> w1(new Widget); |
| 54 Widget::InitParams params; | 52 Widget::InitParams params; |
| 55 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 53 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 56 params.context = ash_test_helper()->CurrentContext(); | 54 params.context = ash_test_helper()->CurrentContext(); |
| 57 w1->Init(params); | 55 w1->Init(params); |
| 58 w1->Show(); | 56 w1->Show(); |
| 59 EXPECT_TRUE(w1->IsActive()); | 57 EXPECT_TRUE(w1->IsActive()); |
| 60 EXPECT_TRUE(w1->IsVisible()); | 58 EXPECT_TRUE(w1->IsVisible()); |
| 61 } | 59 } |
| OLD | NEW |