OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <memory> | 5 #include <memory> |
6 | 6 |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "chrome/test/base/view_event_test_platform_part.h" | 8 #include "chrome/test/base/view_event_test_platform_part.h" |
9 #include "ui/aura/env.h" | 9 #include "ui/aura/env.h" |
10 #include "ui/display/screen.h" | 10 #include "ui/display/screen.h" |
11 #include "ui/views/widget/desktop_aura/desktop_screen.h" | 11 #include "ui/views/widget/desktop_aura/desktop_screen.h" |
12 | 12 |
| 13 #if !defined(OS_CHROMEOS) && defined(OS_LINUX) |
| 14 #include "ui/views/test/test_desktop_screen_x11.h" |
| 15 #endif |
| 16 |
13 namespace { | 17 namespace { |
14 | 18 |
15 // ViewEventTestPlatformPart implementation for Views, but non-CrOS. | 19 // ViewEventTestPlatformPart implementation for Views, but non-CrOS. |
16 class ViewEventTestPlatformPartDefault : public ViewEventTestPlatformPart { | 20 class ViewEventTestPlatformPartDefault : public ViewEventTestPlatformPart { |
17 public: | 21 public: |
18 explicit ViewEventTestPlatformPartDefault( | 22 explicit ViewEventTestPlatformPartDefault( |
19 ui::ContextFactory* context_factory) { | 23 ui::ContextFactory* context_factory) { |
20 #if defined(USE_AURA) | 24 #if defined(USE_AURA) |
| 25 DCHECK(!display::Screen::GetScreen()); |
| 26 #if !defined(OS_CHROMEOS) && defined(OS_LINUX) |
| 27 display::Screen::SetScreenInstance( |
| 28 views::test::TestDesktopScreenX11::GetInstance()); |
| 29 #else |
21 screen_.reset(views::CreateDesktopScreen()); | 30 screen_.reset(views::CreateDesktopScreen()); |
22 display::Screen::SetScreenInstance(screen_.get()); | 31 display::Screen::SetScreenInstance(screen_.get()); |
| 32 #endif |
23 env_ = aura::Env::CreateInstance(); | 33 env_ = aura::Env::CreateInstance(); |
24 env_->set_context_factory(context_factory); | 34 env_->set_context_factory(context_factory); |
25 #endif | 35 #endif |
26 } | 36 } |
27 | 37 |
28 ~ViewEventTestPlatformPartDefault() override { | 38 ~ViewEventTestPlatformPartDefault() override { |
29 #if defined(USE_AURA) | 39 #if defined(USE_AURA) |
30 env_.reset(); | 40 env_.reset(); |
31 display::Screen::SetScreenInstance(nullptr); | 41 display::Screen::SetScreenInstance(nullptr); |
32 #endif | 42 #endif |
33 } | 43 } |
34 | 44 |
35 // Overridden from ViewEventTestPlatformPart: | 45 // Overridden from ViewEventTestPlatformPart: |
36 gfx::NativeWindow GetContext() override { return NULL; } | 46 gfx::NativeWindow GetContext() override { return NULL; } |
37 | 47 |
38 private: | 48 private: |
39 std::unique_ptr<display::Screen> screen_; | 49 std::unique_ptr<display::Screen> screen_; |
40 std::unique_ptr<aura::Env> env_; | 50 std::unique_ptr<aura::Env> env_; |
41 | 51 |
42 DISALLOW_COPY_AND_ASSIGN(ViewEventTestPlatformPartDefault); | 52 DISALLOW_COPY_AND_ASSIGN(ViewEventTestPlatformPartDefault); |
43 }; | 53 }; |
44 | 54 |
45 } // namespace | 55 } // namespace |
46 | 56 |
47 // static | 57 // static |
48 ViewEventTestPlatformPart* ViewEventTestPlatformPart::Create( | 58 ViewEventTestPlatformPart* ViewEventTestPlatformPart::Create( |
49 ui::ContextFactory* context_factory) { | 59 ui::ContextFactory* context_factory) { |
50 return new ViewEventTestPlatformPartDefault(context_factory); | 60 return new ViewEventTestPlatformPartDefault(context_factory); |
51 } | 61 } |
OLD | NEW |