OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/interactive_ui/view_event_test_base.h" | 5 #include "chrome/test/interactive_ui/view_event_test_base.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <ole2.h> | 8 #include <ole2.h> |
9 #endif | 9 #endif |
10 | 10 |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
14 #include "chrome/browser/automation/ui_controls.h" | 14 #include "chrome/browser/automation/ui_controls.h" |
| 15 #include "chrome/test/ui_test_utils.h" |
15 #include "views/view.h" | 16 #include "views/view.h" |
16 #include "views/window/window.h" | 17 #include "views/window/window.h" |
17 | 18 |
18 namespace { | 19 namespace { |
19 | 20 |
20 // Default delay for the time-out at which we stop message loop. | 21 // Default delay for the time-out at which we stop message loop. |
21 const int kTimeoutInMS = 20000; | 22 const int kTimeoutInMS = 20000; |
22 | 23 |
23 // View subclass that allows you to specify the preferred size. | 24 // View subclass that allows you to specify the preferred size. |
24 class TestView : public views::View { | 25 class TestView : public views::View { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 OleInitialize(NULL); | 81 OleInitialize(NULL); |
81 #endif | 82 #endif |
82 window_ = views::Window::CreateChromeWindow(NULL, gfx::Rect(), this); | 83 window_ = views::Window::CreateChromeWindow(NULL, gfx::Rect(), this); |
83 } | 84 } |
84 | 85 |
85 void ViewEventTestBase::TearDown() { | 86 void ViewEventTestBase::TearDown() { |
86 if (window_) { | 87 if (window_) { |
87 #if defined(OS_WIN) | 88 #if defined(OS_WIN) |
88 DestroyWindow(window_->GetNativeWindow()); | 89 DestroyWindow(window_->GetNativeWindow()); |
89 #else | 90 #else |
90 gtk_widget_destroy(GTK_WIDGET(window_->GetNativeWindow())); | 91 window_->Close(); |
| 92 MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask()); |
| 93 ui_test_utils::RunMessageLoop(); |
91 #endif | 94 #endif |
92 window_ = NULL; | 95 window_ = NULL; |
93 } | 96 } |
94 #if defined(OS_WIN) | 97 #if defined(OS_WIN) |
95 OleUninitialize(); | 98 OleUninitialize(); |
96 #endif | 99 #endif |
97 } | 100 } |
98 | 101 |
99 views::View* ViewEventTestBase::GetContentsView() { | 102 views::View* ViewEventTestBase::GetContentsView() { |
100 if (!content_view_) { | 103 if (!content_view_) { |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 | 165 |
163 void ViewEventTestBase::TimedOut() { | 166 void ViewEventTestBase::TimedOut() { |
164 std::string error_message = "Test timed out. Each test runs for a max of "; | 167 std::string error_message = "Test timed out. Each test runs for a max of "; |
165 error_message += IntToString(kTimeoutInMS); | 168 error_message += IntToString(kTimeoutInMS); |
166 error_message += " ms (kTimeoutInMS)."; | 169 error_message += " ms (kTimeoutInMS)."; |
167 | 170 |
168 GTEST_NONFATAL_FAILURE_(error_message.c_str()); | 171 GTEST_NONFATAL_FAILURE_(error_message.c_str()); |
169 | 172 |
170 Done(); | 173 Done(); |
171 } | 174 } |
OLD | NEW |