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

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

Issue 2758323002: Broke out layout metric information from ViewsDelegate to LayoutProvider (Closed)
Patch Set: Final feedback addressed Created 3 years, 8 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/scoped_views_test_helper.h ('k') | ui/views/test/test_views_delegate.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/views/test/platform_test_helper.h" 14 #include "ui/views/test/platform_test_helper.h"
15 #include "ui/views/test/test_views_delegate.h" 15 #include "ui/views/test/test_views_delegate.h"
16 #include "ui/views/test/views_test_helper.h" 16 #include "ui/views/test/views_test_helper.h"
17 17
18 namespace views { 18 namespace views {
19 19
20 ScopedViewsTestHelper::ScopedViewsTestHelper() 20 ScopedViewsTestHelper::ScopedViewsTestHelper()
21 : ScopedViewsTestHelper(base::WrapUnique(new TestViewsDelegate)) {} 21 : ScopedViewsTestHelper(base::WrapUnique(new TestViewsDelegate)) {}
22 22
23 ScopedViewsTestHelper::ScopedViewsTestHelper( 23 ScopedViewsTestHelper::ScopedViewsTestHelper(
24 std::unique_ptr<TestViewsDelegate> views_delegate) 24 std::unique_ptr<TestViewsDelegate> views_delegate)
25 : views_delegate_(std::move(views_delegate)), 25 : test_views_delegate_(std::move(views_delegate)),
26 platform_test_helper_(PlatformTestHelper::Create()) { 26 platform_test_helper_(PlatformTestHelper::Create()) {
27 // The ContextFactory must exist before any Compositors are created. 27 // The ContextFactory must exist before any Compositors are created.
28 ui::ContextFactory* context_factory = nullptr; 28 ui::ContextFactory* context_factory = nullptr;
29 ui::ContextFactoryPrivate* context_factory_private = nullptr; 29 ui::ContextFactoryPrivate* context_factory_private = nullptr;
30 platform_test_helper_->InitializeContextFactory(&context_factory, 30 platform_test_helper_->InitializeContextFactory(&context_factory,
31 &context_factory_private); 31 &context_factory_private);
32 32
33 views_delegate_->set_context_factory(context_factory); 33 test_views_delegate_->set_context_factory(context_factory);
34 views_delegate_->set_context_factory_private(context_factory_private); 34 test_views_delegate_->set_context_factory_private(context_factory_private);
35 35
36 test_helper_.reset(ViewsTestHelper::Create(base::MessageLoopForUI::current(), 36 test_helper_.reset(ViewsTestHelper::Create(base::MessageLoopForUI::current(),
37 context_factory, 37 context_factory,
38 context_factory_private)); 38 context_factory_private));
39 platform_test_helper_->OnTestHelperCreated(test_helper_.get()); 39 platform_test_helper_->OnTestHelperCreated(test_helper_.get());
40 test_helper_->SetUp(); 40 test_helper_->SetUp();
41 41
42 ui::InitializeInputMethodForTesting(); 42 ui::InitializeInputMethodForTesting();
43 ui::TestClipboard::CreateForCurrentThread(); 43 ui::TestClipboard::CreateForCurrentThread();
44 } 44 }
45 45
46 ScopedViewsTestHelper::~ScopedViewsTestHelper() { 46 ScopedViewsTestHelper::~ScopedViewsTestHelper() {
47 ui::Clipboard::DestroyClipboardForCurrentThread(); 47 ui::Clipboard::DestroyClipboardForCurrentThread();
48 ui::ShutdownInputMethodForTesting(); 48 ui::ShutdownInputMethodForTesting();
49 test_helper_->TearDown(); 49 test_helper_->TearDown();
50 test_helper_.reset(); 50 test_helper_.reset();
51 51
52 views_delegate_.reset(); 52 test_views_delegate_.reset();
53 53
54 // The Mus PlatformTestHelper has state that is deleted by 54 // The Mus PlatformTestHelper has state that is deleted by
55 // ui::TerminateContextFactoryForTests(). 55 // ui::TerminateContextFactoryForTests().
56 platform_test_helper_.reset(); 56 platform_test_helper_.reset();
57 } 57 }
58 58
59 gfx::NativeWindow ScopedViewsTestHelper::GetContext() { 59 gfx::NativeWindow ScopedViewsTestHelper::GetContext() {
60 return test_helper_->GetContext(); 60 return test_helper_->GetContext();
61 } 61 }
62 62
63 } // namespace views 63 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/test/scoped_views_test_helper.h ('k') | ui/views/test/test_views_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698