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

Side by Side Diff: chrome/test/base/view_event_test_platform_part_aura.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
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 "base/memory/ptr_util.h"
8 #include "chrome/test/base/view_event_test_platform_part.h" 9 #include "chrome/test/base/view_event_test_platform_part.h"
9 #include "ui/aura/env.h" 10 #include "ui/aura/env.h"
10 #include "ui/display/screen.h" 11 #include "ui/display/screen.h"
12 #include "ui/views/test/platform_test_helper.h"
11 #include "ui/views/widget/desktop_aura/desktop_screen.h" 13 #include "ui/views/widget/desktop_aura/desktop_screen.h"
14 #include "ui/wm/core/wm_state.h"
12 15
13 #if !defined(OS_CHROMEOS) && defined(OS_LINUX) 16 #if defined(USE_X11)
14 #include "ui/views/test/test_desktop_screen_x11.h" 17 #include "ui/views/test/test_desktop_screen_x11.h"
15 #endif 18 #endif
16 19
17 namespace { 20 namespace {
18 21
19 // ViewEventTestPlatformPart implementation for Views, but non-CrOS. 22 // ViewEventTestPlatformPart implementation for Aura Views, but non-CrOS.
20 class ViewEventTestPlatformPartDefault : public ViewEventTestPlatformPart { 23 class ViewEventTestPlatformPartAura : public ViewEventTestPlatformPart {
21 public: 24 public:
22 ViewEventTestPlatformPartDefault( 25 ViewEventTestPlatformPartAura(
23 ui::ContextFactory* context_factory, 26 ui::ContextFactory* context_factory,
24 ui::ContextFactoryPrivate* context_factory_private) { 27 ui::ContextFactoryPrivate* context_factory_private) {
25 #if defined(USE_AURA)
26 DCHECK(!display::Screen::GetScreen()); 28 DCHECK(!display::Screen::GetScreen());
27 #if defined(USE_X11) && !defined(OS_CHROMEOS) 29 #if defined(USE_X11)
28 display::Screen::SetScreenInstance( 30 display::Screen::SetScreenInstance(
29 views::test::TestDesktopScreenX11::GetInstance()); 31 views::test::TestDesktopScreenX11::GetInstance());
30 #else 32 #else
31 screen_.reset(views::CreateDesktopScreen()); 33 screen_.reset(views::CreateDesktopScreen());
32 display::Screen::SetScreenInstance(screen_.get()); 34 display::Screen::SetScreenInstance(screen_.get());
33 #endif 35 #endif
34 env_ = aura::Env::CreateInstance(); 36 env_ = aura::Env::CreateInstance();
35 env_->set_context_factory(context_factory); 37 env_->set_context_factory(context_factory);
36 env_->set_context_factory_private(context_factory_private); 38 env_->set_context_factory_private(context_factory_private);
37 #endif 39
40 // See AuraTestHelper::SetUp().
41 if (!views::PlatformTestHelper::IsMus())
42 wm_state_ = base::MakeUnique<wm::WMState>();
tapted 2017/01/23 10:52:55 Some menu-related interactive_ui_tests fail with `
38 } 43 }
39 44
40 ~ViewEventTestPlatformPartDefault() override { 45 ~ViewEventTestPlatformPartAura() override {
41 #if defined(USE_AURA) 46 wm_state_.reset();
42 env_.reset(); 47 env_.reset();
43 display::Screen::SetScreenInstance(nullptr); 48 display::Screen::SetScreenInstance(nullptr);
44 #endif
45 } 49 }
46 50
47 // Overridden from ViewEventTestPlatformPart: 51 // ViewEventTestPlatformPart:
48 gfx::NativeWindow GetContext() override { return NULL; } 52 gfx::NativeWindow GetContext() override { return nullptr; }
49 53
50 private: 54 private:
51 std::unique_ptr<display::Screen> screen_; 55 std::unique_ptr<display::Screen> screen_;
52 std::unique_ptr<aura::Env> env_; 56 std::unique_ptr<aura::Env> env_;
57 std::unique_ptr<wm::WMState> wm_state_;
53 58
54 DISALLOW_COPY_AND_ASSIGN(ViewEventTestPlatformPartDefault); 59 DISALLOW_COPY_AND_ASSIGN(ViewEventTestPlatformPartAura);
55 }; 60 };
56 61
57 } // namespace 62 } // namespace
58 63
59 // static 64 // static
60 ViewEventTestPlatformPart* ViewEventTestPlatformPart::Create( 65 ViewEventTestPlatformPart* ViewEventTestPlatformPart::Create(
61 ui::ContextFactory* context_factory, 66 ui::ContextFactory* context_factory,
62 ui::ContextFactoryPrivate* context_factory_private) { 67 ui::ContextFactoryPrivate* context_factory_private) {
63 return new ViewEventTestPlatformPartDefault(context_factory, 68 return new ViewEventTestPlatformPartAura(context_factory,
64 context_factory_private); 69 context_factory_private);
65 } 70 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698