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

Side by Side Diff: ui/views/test/scoped_views_test_helper.cc

Issue 2611773002: Removes code using mus client lib (Closed)
Patch Set: dont run on linux 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
« no previous file with comments | « ui/views/test/platform_test_helper.cc ('k') | ui/views/test/views_test_base.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "ui/views/test/scoped_views_test_helper.h" 5 #include "ui/views/test/scoped_views_test_helper.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
11 #include "ui/base/clipboard/clipboard.h" 11 #include "ui/base/clipboard/clipboard.h"
12 #include "ui/base/ime/input_method_initializer.h" 12 #include "ui/base/ime/input_method_initializer.h"
13 #include "ui/base/test/test_clipboard.h" 13 #include "ui/base/test/test_clipboard.h"
14 #include "ui/compositor/test/context_factories_for_test.h" 14 #include "ui/compositor/test/context_factories_for_test.h"
15 #include "ui/views/test/platform_test_helper.h" 15 #include "ui/views/test/platform_test_helper.h"
16 #include "ui/views/test/test_views_delegate.h" 16 #include "ui/views/test/test_views_delegate.h"
17 #include "ui/views/test/views_test_helper.h" 17 #include "ui/views/test/views_test_helper.h"
18 18
19 #if defined(USE_AURA)
20 #include "ui/aura/env.h"
21 #endif
22
23 namespace views { 19 namespace views {
24 20
25 ScopedViewsTestHelper::ScopedViewsTestHelper() 21 ScopedViewsTestHelper::ScopedViewsTestHelper()
26 : ScopedViewsTestHelper(base::WrapUnique(new TestViewsDelegate)) {} 22 : ScopedViewsTestHelper(base::WrapUnique(new TestViewsDelegate)) {}
27 23
28 ScopedViewsTestHelper::ScopedViewsTestHelper( 24 ScopedViewsTestHelper::ScopedViewsTestHelper(
29 std::unique_ptr<TestViewsDelegate> views_delegate) 25 std::unique_ptr<TestViewsDelegate> views_delegate)
30 : views_delegate_(std::move(views_delegate)), 26 : views_delegate_(std::move(views_delegate)),
31 platform_test_helper_(PlatformTestHelper::Create()) { 27 platform_test_helper_(PlatformTestHelper::Create()) {
32 // The ContextFactory must exist before any Compositors are created. 28 // The ContextFactory must exist before any Compositors are created.
33 bool enable_pixel_output = false; 29 bool enable_pixel_output = false;
34 #if defined(USE_AURA)
35 ui::ContextFactory* old_context_factory = nullptr;
36 ui::ContextFactoryPrivate* old_context_factory_private = nullptr;
37 if (PlatformTestHelper::IsMus()) {
38 old_context_factory = aura::Env::GetInstance()->context_factory();
39 DCHECK(old_context_factory);
40 old_context_factory_private =
41 aura::Env::GetInstance()->context_factory_private();
42 }
43 #endif
44 ui::ContextFactory* context_factory = nullptr; 30 ui::ContextFactory* context_factory = nullptr;
45 ui::ContextFactoryPrivate* context_factory_private = nullptr; 31 ui::ContextFactoryPrivate* context_factory_private = nullptr;
46 ui::InitializeContextFactoryForTests(enable_pixel_output, &context_factory, 32 ui::InitializeContextFactoryForTests(enable_pixel_output, &context_factory,
47 &context_factory_private); 33 &context_factory_private);
48 34
49 views_delegate_->set_context_factory(context_factory); 35 views_delegate_->set_context_factory(context_factory);
50 views_delegate_->set_context_factory_private(context_factory_private); 36 views_delegate_->set_context_factory_private(context_factory_private);
51 37
52 test_helper_.reset(ViewsTestHelper::Create(base::MessageLoopForUI::current(), 38 test_helper_.reset(ViewsTestHelper::Create(base::MessageLoopForUI::current(),
53 context_factory, 39 context_factory,
54 context_factory_private)); 40 context_factory_private));
55 platform_test_helper_->OnTestHelperCreated(test_helper_.get()); 41 platform_test_helper_->OnTestHelperCreated(test_helper_.get());
56 test_helper_->SetUp(); 42 test_helper_->SetUp();
57 43
58 #if defined(USE_AURA)
59 // When running inside mus, the context-factory from
60 // ui::InitializeContextFactoryForTests() is only needed for the default
61 // WindowTreeHost instance created by TestScreen. After that, the
62 // context-factory is used when creating Widgets (to set-up the compositor for
63 // the corresponding ui::Windows). So restore the context-factory (which
64 // WindowManagerConnection would have set up), so that NativeWidgetMus
65 // installs the correct context-factory that can talk to mus.
66 if (PlatformTestHelper::IsMus()) {
67 aura::Env::GetInstance()->set_context_factory(old_context_factory);
68 aura::Env::GetInstance()->set_context_factory_private(
69 old_context_factory_private);
70 }
71 #endif
72
73 ui::InitializeInputMethodForTesting(); 44 ui::InitializeInputMethodForTesting();
74 ui::TestClipboard::CreateForCurrentThread(); 45 ui::TestClipboard::CreateForCurrentThread();
75 } 46 }
76 47
77 ScopedViewsTestHelper::~ScopedViewsTestHelper() { 48 ScopedViewsTestHelper::~ScopedViewsTestHelper() {
78 ui::Clipboard::DestroyClipboardForCurrentThread(); 49 ui::Clipboard::DestroyClipboardForCurrentThread();
79 ui::ShutdownInputMethodForTesting(); 50 ui::ShutdownInputMethodForTesting();
80 test_helper_->TearDown(); 51 test_helper_->TearDown();
81 test_helper_.reset(); 52 test_helper_.reset();
82 53
83 views_delegate_.reset(); 54 views_delegate_.reset();
84 55
85 // The Mus PlatformTestHelper has state that is deleted by 56 // The Mus PlatformTestHelper has state that is deleted by
86 // ui::TerminateContextFactoryForTests(). 57 // ui::TerminateContextFactoryForTests().
87 platform_test_helper_.reset(); 58 platform_test_helper_.reset();
88 59
89 ui::TerminateContextFactoryForTests(); 60 ui::TerminateContextFactoryForTests();
90 } 61 }
91 62
92 gfx::NativeWindow ScopedViewsTestHelper::GetContext() { 63 gfx::NativeWindow ScopedViewsTestHelper::GetContext() {
93 return test_helper_->GetContext(); 64 return test_helper_->GetContext();
94 } 65 }
95 66
96 } // namespace views 67 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/test/platform_test_helper.cc ('k') | ui/views/test/views_test_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698