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 "ui/views/test/views_test_base.h" | 5 #include "ui/views/test/views_test_base.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
| 9 #include "base/environment.h" |
9 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
10 #include "ui/base/clipboard/clipboard.h" | 11 #include "ui/base/clipboard/clipboard.h" |
11 #include "ui/base/material_design/material_design_controller.h" | 12 #include "ui/base/material_design/material_design_controller.h" |
12 #include "ui/base/test/material_design_controller_test_api.h" | 13 #include "ui/base/test/material_design_controller_test_api.h" |
13 #include "ui/views/test/platform_test_helper.h" | 14 #include "ui/views/test/platform_test_helper.h" |
14 | 15 |
| 16 #if defined(USE_X11) && !defined(OS_CHROMEOS) |
| 17 #include "ui/base/x/x11_util_internal.h" |
| 18 #endif |
| 19 |
15 namespace views { | 20 namespace views { |
16 | 21 |
| 22 namespace { |
| 23 |
| 24 bool InitializeVisuals() { |
| 25 #if defined(USE_X11) && !defined(OS_CHROMEOS) |
| 26 static int depth = 0; |
| 27 static bool has_compositing_manager = false; |
| 28 |
| 29 if (depth > 0) |
| 30 return has_compositing_manager; |
| 31 |
| 32 // testing/xvfb.py runs xvfb and xcompmgr. |
| 33 std::unique_ptr<base::Environment> env(base::Environment::Create()); |
| 34 has_compositing_manager = env->HasVar("_CHROMIUM_INSIDE_XVFB"); |
| 35 ui::ChooseVisualForWindow(has_compositing_manager, NULL, &depth); |
| 36 |
| 37 if (has_compositing_manager) |
| 38 EXPECT_EQ(32, depth); |
| 39 |
| 40 return has_compositing_manager; |
| 41 #else |
| 42 return false; |
| 43 #endif |
| 44 } |
| 45 |
| 46 } // namespace |
| 47 |
17 ViewsTestBase::ViewsTestBase() | 48 ViewsTestBase::ViewsTestBase() |
18 : setup_called_(false), | 49 : setup_called_(false), |
19 teardown_called_(false) { | 50 teardown_called_(false), |
20 } | 51 has_compositing_manager_(InitializeVisuals()) {} |
21 | 52 |
22 ViewsTestBase::~ViewsTestBase() { | 53 ViewsTestBase::~ViewsTestBase() { |
23 CHECK(setup_called_) | 54 CHECK(setup_called_) |
24 << "You have overridden SetUp but never called super class's SetUp"; | 55 << "You have overridden SetUp but never called super class's SetUp"; |
25 CHECK(teardown_called_) | 56 CHECK(teardown_called_) |
26 << "You have overridden TearDown but never called super class's TearDown"; | 57 << "You have overridden TearDown but never called super class's TearDown"; |
27 } | 58 } |
28 | 59 |
29 // static | 60 // static |
30 bool ViewsTestBase::IsMus() { | 61 bool ViewsTestBase::IsMus() { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 Widget::InitParams::Type type) { | 96 Widget::InitParams::Type type) { |
66 Widget::InitParams params(type); | 97 Widget::InitParams params(type); |
67 params.context = GetContext(); | 98 params.context = GetContext(); |
68 return params; | 99 return params; |
69 } | 100 } |
70 | 101 |
71 gfx::NativeWindow ViewsTestBase::GetContext() { | 102 gfx::NativeWindow ViewsTestBase::GetContext() { |
72 return test_helper_->GetContext(); | 103 return test_helper_->GetContext(); |
73 } | 104 } |
74 | 105 |
| 106 bool ViewsTestBase::HasCompositingManager() const { |
| 107 return has_compositing_manager_; |
| 108 } |
| 109 |
75 } // namespace views | 110 } // namespace views |
OLD | NEW |