Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(93)

Side by Side Diff: chrome/test/base/view_event_test_platform_part_default.cc

Issue 2645253002: DesktopAura: Track windows "owned" via the DesktopWindowTreeHost (Closed)
Patch Set: simpler Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include <memory>
6
7 #include "base/macros.h"
8 #include "chrome/test/base/view_event_test_platform_part.h"
9 #include "ui/aura/env.h"
10 #include "ui/display/screen.h"
11 #include "ui/views/widget/desktop_aura/desktop_screen.h"
12
13 #if !defined(OS_CHROMEOS) && defined(OS_LINUX)
14 #include "ui/views/test/test_desktop_screen_x11.h"
15 #endif
16
17 namespace {
18
19 // ViewEventTestPlatformPart implementation for Views, but non-CrOS.
20 class ViewEventTestPlatformPartDefault : public ViewEventTestPlatformPart {
21 public:
22 ViewEventTestPlatformPartDefault(
23 ui::ContextFactory* context_factory,
24 ui::ContextFactoryPrivate* context_factory_private) {
25 #if defined(USE_AURA)
26 DCHECK(!display::Screen::GetScreen());
27 #if defined(USE_X11) && !defined(OS_CHROMEOS)
28 display::Screen::SetScreenInstance(
29 views::test::TestDesktopScreenX11::GetInstance());
30 #else
31 screen_.reset(views::CreateDesktopScreen());
32 display::Screen::SetScreenInstance(screen_.get());
33 #endif
34 env_ = aura::Env::CreateInstance();
35 env_->set_context_factory(context_factory);
36 env_->set_context_factory_private(context_factory_private);
37 #endif
38 }
39
40 ~ViewEventTestPlatformPartDefault() override {
41 #if defined(USE_AURA)
42 env_.reset();
43 display::Screen::SetScreenInstance(nullptr);
44 #endif
45 }
46
47 // Overridden from ViewEventTestPlatformPart:
48 gfx::NativeWindow GetContext() override { return NULL; }
49
50 private:
51 std::unique_ptr<display::Screen> screen_;
52 std::unique_ptr<aura::Env> env_;
53
54 DISALLOW_COPY_AND_ASSIGN(ViewEventTestPlatformPartDefault);
55 };
56
57 } // namespace
58
59 // static
60 ViewEventTestPlatformPart* ViewEventTestPlatformPart::Create(
61 ui::ContextFactory* context_factory,
62 ui::ContextFactoryPrivate* context_factory_private) {
63 return new ViewEventTestPlatformPartDefault(context_factory,
64 context_factory_private);
65 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698