| 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 |
| 11 #if defined(OS_WIN) |
| 12 #include "base/win/windows_version.h" |
| 13 #endif |
| 14 |
| 11 // 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 |
| 12 // the tests? | 16 // the tests? |
| 13 class AshTestHelperTest : public testing::Test { | 17 class AshTestHelperTest : public testing::Test { |
| 14 public: | 18 public: |
| 15 AshTestHelperTest() {} | 19 AshTestHelperTest() {} |
| 16 virtual ~AshTestHelperTest() {} | 20 virtual ~AshTestHelperTest() {} |
| 17 | 21 |
| 18 virtual void SetUp() OVERRIDE { | 22 virtual void SetUp() OVERRIDE { |
| 19 testing::Test::SetUp(); | 23 testing::Test::SetUp(); |
| 20 ash_test_helper_.reset(new ash::test::AshTestHelper(&message_loop_)); | 24 ash_test_helper_.reset(new ash::test::AshTestHelper(&message_loop_)); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 33 private: | 37 private: |
| 34 base::MessageLoopForUI message_loop_; | 38 base::MessageLoopForUI message_loop_; |
| 35 scoped_ptr<ash::test::AshTestHelper> ash_test_helper_; | 39 scoped_ptr<ash::test::AshTestHelper> ash_test_helper_; |
| 36 | 40 |
| 37 DISALLOW_COPY_AND_ASSIGN(AshTestHelperTest); | 41 DISALLOW_COPY_AND_ASSIGN(AshTestHelperTest); |
| 38 }; | 42 }; |
| 39 | 43 |
| 40 // Ensure that we have initialized enough of Ash to create and show a window. | 44 // Ensure that we have initialized enough of Ash to create and show a window. |
| 41 TEST_F(AshTestHelperTest, AshTestHelper) { | 45 TEST_F(AshTestHelperTest, AshTestHelper) { |
| 42 // Check initial state. | 46 // Check initial state. |
| 47 #if defined(OS_WIN) |
| 48 // Ash doesn't run on versions of Windows prior to Win7. |
| 49 if (base::win::GetVersion() < base::win::VERSION_WIN7) |
| 50 return; |
| 51 #endif |
| 43 EXPECT_TRUE(ash_test_helper()->message_loop()); | 52 EXPECT_TRUE(ash_test_helper()->message_loop()); |
| 44 EXPECT_TRUE(ash_test_helper()->test_shell_delegate()); | 53 EXPECT_TRUE(ash_test_helper()->test_shell_delegate()); |
| 45 EXPECT_TRUE(ash_test_helper()->CurrentContext()); | 54 EXPECT_TRUE(ash_test_helper()->CurrentContext()); |
| 46 | 55 |
| 47 // Enough state is initialized to create a window. | 56 // Enough state is initialized to create a window. |
| 48 using views::Widget; | 57 using views::Widget; |
| 49 scoped_ptr<Widget> w1(new Widget); | 58 scoped_ptr<Widget> w1(new Widget); |
| 50 Widget::InitParams params; | 59 Widget::InitParams params; |
| 51 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 60 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 52 params.context = ash_test_helper()->CurrentContext(); | 61 params.context = ash_test_helper()->CurrentContext(); |
| 53 w1->Init(params); | 62 w1->Init(params); |
| 54 w1->Show(); | 63 w1->Show(); |
| 55 EXPECT_TRUE(w1->IsActive()); | 64 EXPECT_TRUE(w1->IsActive()); |
| 56 EXPECT_TRUE(w1->IsVisible()); | 65 EXPECT_TRUE(w1->IsVisible()); |
| 57 } | 66 } |
| OLD | NEW |