| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/test/base/view_event_test_base.h" | 5 #include "chrome/test/base/view_event_test_base.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 #include "ash/test/test_shell_delegate.h" | 27 #include "ash/test/test_shell_delegate.h" |
| 28 #endif | 28 #endif |
| 29 | 29 |
| 30 #if defined(USE_AURA) | 30 #if defined(USE_AURA) |
| 31 #include "ui/aura/client/event_client.h" | 31 #include "ui/aura/client/event_client.h" |
| 32 #include "ui/aura/env.h" | 32 #include "ui/aura/env.h" |
| 33 #include "ui/aura/root_window.h" | 33 #include "ui/aura/root_window.h" |
| 34 #include "ui/aura/test/aura_test_helper.h" | 34 #include "ui/aura/test/aura_test_helper.h" |
| 35 #endif | 35 #endif |
| 36 | 36 |
| 37 #if defined(OS_WIN) |
| 38 #include "base/win/metro.h" |
| 39 #include "ui/base/ime/win/tsf_bridge.h" |
| 40 #endif |
| 41 |
| 37 namespace { | 42 namespace { |
| 38 | 43 |
| 39 // View subclass that allows you to specify the preferred size. | 44 // View subclass that allows you to specify the preferred size. |
| 40 class TestView : public views::View { | 45 class TestView : public views::View { |
| 41 public: | 46 public: |
| 42 TestView() {} | 47 TestView() {} |
| 43 | 48 |
| 44 void SetPreferredSize(const gfx::Size& size) { | 49 void SetPreferredSize(const gfx::Size& size) { |
| 45 preferred_size_ = size; | 50 preferred_size_ = size; |
| 46 PreferredSizeChanged(); | 51 PreferredSizeChanged(); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 ash::Shell::CreateInstance(new ash::test::TestShellDelegate()); | 115 ash::Shell::CreateInstance(new ash::test::TestShellDelegate()); |
| 111 context = ash::Shell::GetPrimaryRootWindow(); | 116 context = ash::Shell::GetPrimaryRootWindow(); |
| 112 #endif | 117 #endif |
| 113 #elif defined(USE_AURA) | 118 #elif defined(USE_AURA) |
| 114 // Instead of using the ash shell, use an AuraTestHelper to create and manage | 119 // Instead of using the ash shell, use an AuraTestHelper to create and manage |
| 115 // the test screen. | 120 // the test screen. |
| 116 aura_test_helper_.reset(new aura::test::AuraTestHelper(&message_loop_)); | 121 aura_test_helper_.reset(new aura::test::AuraTestHelper(&message_loop_)); |
| 117 aura_test_helper_->SetUp(); | 122 aura_test_helper_->SetUp(); |
| 118 context = aura_test_helper_->root_window(); | 123 context = aura_test_helper_->root_window(); |
| 119 #endif | 124 #endif |
| 120 | 125 #if defined(OS_WIN) |
| 126 if (base::win::IsTSFAwareRequired()) |
| 127 ui::TSFBridge::Initialize(); |
| 128 #endif |
| 121 window_ = views::Widget::CreateWindowWithContext(this, context); | 129 window_ = views::Widget::CreateWindowWithContext(this, context); |
| 122 } | 130 } |
| 123 | 131 |
| 124 void ViewEventTestBase::TearDown() { | 132 void ViewEventTestBase::TearDown() { |
| 125 if (window_) { | 133 if (window_) { |
| 126 #if defined(OS_WIN) && !defined(USE_AURA) | 134 #if defined(OS_WIN) && !defined(USE_AURA) |
| 127 DestroyWindow(window_->GetNativeWindow()); | 135 DestroyWindow(window_->GetNativeWindow()); |
| 128 #else | 136 #else |
| 129 window_->Close(); | 137 window_->Close(); |
| 130 content::RunAllPendingInMessageLoop(); | 138 content::RunAllPendingInMessageLoop(); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 dnd_thread_.reset(NULL); | 219 dnd_thread_.reset(NULL); |
| 212 } | 220 } |
| 213 | 221 |
| 214 void ViewEventTestBase::RunTestMethod(const base::Closure& task) { | 222 void ViewEventTestBase::RunTestMethod(const base::Closure& task) { |
| 215 StopBackgroundThread(); | 223 StopBackgroundThread(); |
| 216 | 224 |
| 217 task.Run(); | 225 task.Run(); |
| 218 if (HasFatalFailure()) | 226 if (HasFatalFailure()) |
| 219 Done(); | 227 Done(); |
| 220 } | 228 } |
| OLD | NEW |