| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef UI_VIEWS_TEST_VIEWS_TEST_BASE_H_ | 5 #ifndef UI_VIEWS_TEST_VIEWS_TEST_BASE_H_ |
| 6 #define UI_VIEWS_TEST_VIEWS_TEST_BASE_H_ | 6 #define UI_VIEWS_TEST_VIEWS_TEST_BASE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 #include "ui/views/test/test_views_delegate.h" | 12 #include "ui/views/test/test_views_delegate.h" |
| 13 | 13 |
| 14 namespace aura { |
| 15 namespace test { |
| 16 class TestActivationClient; |
| 17 } |
| 18 } |
| 19 |
| 14 namespace views { | 20 namespace views { |
| 15 | 21 |
| 16 class TestViewsDelegate; | 22 class TestViewsDelegate; |
| 17 | 23 |
| 18 // A base class for views unit test. It creates a message loop necessary | 24 // A base class for views unit test. It creates a message loop necessary |
| 19 // to drive UI events and takes care of OLE initialization for windows. | 25 // to drive UI events and takes care of OLE initialization for windows. |
| 20 class ViewsTestBase : public testing::Test { | 26 class ViewsTestBase : public testing::Test { |
| 21 public: | 27 public: |
| 22 ViewsTestBase(); | 28 ViewsTestBase(); |
| 23 virtual ~ViewsTestBase(); | 29 virtual ~ViewsTestBase(); |
| 24 | 30 |
| 25 // testing::Test: | 31 // testing::Test: |
| 26 virtual void SetUp() OVERRIDE; | 32 virtual void SetUp() OVERRIDE; |
| 27 virtual void TearDown() OVERRIDE; | 33 virtual void TearDown() OVERRIDE; |
| 28 | 34 |
| 29 void RunPendingMessages(); | 35 void RunPendingMessages(); |
| 30 | 36 |
| 31 protected: | 37 protected: |
| 32 TestViewsDelegate& views_delegate() const { return *views_delegate_.get(); } | 38 TestViewsDelegate& views_delegate() const { return *views_delegate_.get(); } |
| 33 | 39 |
| 34 void set_views_delegate(TestViewsDelegate* views_delegate) { | 40 void set_views_delegate(TestViewsDelegate* views_delegate) { |
| 35 views_delegate_.reset(views_delegate); | 41 views_delegate_.reset(views_delegate); |
| 36 } | 42 } |
| 37 | 43 |
| 38 MessageLoop* message_loop() { return &message_loop_; } | 44 MessageLoop* message_loop() { return &message_loop_; } |
| 39 | 45 |
| 40 private: | 46 private: |
| 41 MessageLoopForUI message_loop_; | 47 MessageLoopForUI message_loop_; |
| 42 scoped_ptr<TestViewsDelegate> views_delegate_; | 48 scoped_ptr<TestViewsDelegate> views_delegate_; |
| 49 #if defined(USE_AURA) |
| 50 scoped_ptr<aura::test::TestActivationClient> test_activation_client_; |
| 51 #endif |
| 43 bool setup_called_; | 52 bool setup_called_; |
| 44 bool teardown_called_; | 53 bool teardown_called_; |
| 45 | 54 |
| 46 DISALLOW_COPY_AND_ASSIGN(ViewsTestBase); | 55 DISALLOW_COPY_AND_ASSIGN(ViewsTestBase); |
| 47 }; | 56 }; |
| 48 | 57 |
| 49 } // namespace views | 58 } // namespace views |
| 50 | 59 |
| 51 #endif // UI_VIEWS_TEST_VIEWS_TEST_BASE_H_ | 60 #endif // UI_VIEWS_TEST_VIEWS_TEST_BASE_H_ |
| OLD | NEW |