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

Side by Side Diff: ui/views/mus/views_mus_test_suite.cc

Issue 2026623002: views/mus: Have explicit ownership of views::WindowManagerConnection. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tot-merge Created 4 years, 6 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/mus/views_mus_test_suite.h" 5 #include "ui/views/mus/views_mus_test_suite.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 28 matching lines...) Expand all
39 private: 39 private:
40 DISALLOW_COPY_AND_ASSIGN(DefaultShellClient); 40 DISALLOW_COPY_AND_ASSIGN(DefaultShellClient);
41 }; 41 };
42 42
43 class PlatformTestHelperMus : public PlatformTestHelper { 43 class PlatformTestHelperMus : public PlatformTestHelper {
44 public: 44 public:
45 PlatformTestHelperMus(shell::Connector* connector, 45 PlatformTestHelperMus(shell::Connector* connector,
46 const shell::Identity& identity) { 46 const shell::Identity& identity) {
47 // It is necessary to recreate the WindowManagerConnection for each test, 47 // It is necessary to recreate the WindowManagerConnection for each test,
48 // since a new MessageLoop is created for each test. 48 // since a new MessageLoop is created for each test.
49 WindowManagerConnection::Create(connector, identity); 49 connection_ = WindowManagerConnection::Create(connector, identity);
50 } 50 }
51 ~PlatformTestHelperMus() override { WindowManagerConnection::Reset(); } 51 ~PlatformTestHelperMus() override {}
52 52
53 private: 53 private:
54 std::unique_ptr<WindowManagerConnection> connection_;
55
54 DISALLOW_COPY_AND_ASSIGN(PlatformTestHelperMus); 56 DISALLOW_COPY_AND_ASSIGN(PlatformTestHelperMus);
55 }; 57 };
56 58
57 std::unique_ptr<PlatformTestHelper> CreatePlatformTestHelper( 59 std::unique_ptr<PlatformTestHelper> CreatePlatformTestHelper(
58 const shell::Identity& identity, 60 const shell::Identity& identity,
59 const base::Callback<shell::Connector*(void)>& callback) { 61 const base::Callback<shell::Connector*(void)>& callback) {
60 return base::WrapUnique(new PlatformTestHelperMus(callback.Run(), identity)); 62 return base::WrapUnique(new PlatformTestHelperMus(callback.Run(), identity));
61 } 63 }
62 64
63 } // namespace 65 } // namespace
(...skipping 14 matching lines...) Expand all
78 // connector and identity are available at this point. This is because 80 // connector and identity are available at this point. This is because
79 // WindowManagerConnection needs a ViewsDelegate and a MessageLoop to have 81 // WindowManagerConnection needs a ViewsDelegate and a MessageLoop to have
80 // been installed first. So delay the creation until the necessary 82 // been installed first. So delay the creation until the necessary
81 // dependencies have been met. 83 // dependencies have been met.
82 PlatformTestHelper::set_factory(base::Bind( 84 PlatformTestHelper::set_factory(base::Bind(
83 &CreatePlatformTestHelper, shell_identity_, 85 &CreatePlatformTestHelper, shell_identity_,
84 base::Bind(&ShellConnection::GetConnector, base::Unretained(this)))); 86 base::Bind(&ShellConnection::GetConnector, base::Unretained(this))));
85 } 87 }
86 88
87 ~ShellConnection() { 89 ~ShellConnection() {
88 if (views::WindowManagerConnection::Exists())
89 views::WindowManagerConnection::Reset();
90 base::WaitableEvent wait(base::WaitableEvent::ResetPolicy::AUTOMATIC, 90 base::WaitableEvent wait(base::WaitableEvent::ResetPolicy::AUTOMATIC,
91 base::WaitableEvent::InitialState::NOT_SIGNALED); 91 base::WaitableEvent::InitialState::NOT_SIGNALED);
92 thread_.task_runner()->PostTask( 92 thread_.task_runner()->PostTask(
93 FROM_HERE, base::Bind(&ShellConnection::TearDownConnections, 93 FROM_HERE, base::Bind(&ShellConnection::TearDownConnections,
94 base::Unretained(this), &wait)); 94 base::Unretained(this), &wait));
95 wait.Wait(); 95 wait.Wait();
96 } 96 }
97 97
98 private: 98 private:
99 shell::Connector* GetConnector() { 99 shell::Connector* GetConnector() {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 ViewsTestSuite::Initialize(); 167 ViewsTestSuite::Initialize();
168 shell_connections_.reset(new ShellConnection); 168 shell_connections_.reset(new ShellConnection);
169 } 169 }
170 170
171 void ViewsMusTestSuite::Shutdown() { 171 void ViewsMusTestSuite::Shutdown() {
172 shell_connections_.reset(); 172 shell_connections_.reset();
173 ViewsTestSuite::Shutdown(); 173 ViewsTestSuite::Shutdown();
174 } 174 }
175 175
176 } // namespace views 176 } // namespace views
OLDNEW
« no previous file with comments | « services/navigation/content_client/browser_main_parts.cc ('k') | ui/views/mus/window_manager_connection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698