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