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