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

Unified Diff: ui/views/mus/views_mus_test_suite.cc

Issue 2023933002: views/mus: Recreate WindowManagerConnection for each test. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tot-merge Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ui/views/mus/window_manager_connection.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/mus/views_mus_test_suite.cc
diff --git a/ui/views/mus/views_mus_test_suite.cc b/ui/views/mus/views_mus_test_suite.cc
index 8290d54ef78bafcc0665b749805f1562cfe9abbd..ea8e031c8e95391819f71564661c9a0d699c296b 100644
--- a/ui/views/mus/views_mus_test_suite.cc
+++ b/ui/views/mus/views_mus_test_suite.cc
@@ -42,24 +42,22 @@ class DefaultShellClient : public shell::ShellClient {
class PlatformTestHelperMus : public PlatformTestHelper {
public:
- PlatformTestHelperMus() {
- ViewsDelegate::GetInstance()->set_native_widget_factory(base::Bind(
- &WindowManagerConnection::CreateNativeWidgetMus,
- base::Unretained(WindowManagerConnection::Get()),
- std::map<std::string, std::vector<uint8_t>>()));
+ PlatformTestHelperMus(shell::Connector* connector,
+ const shell::Identity& identity) {
+ // It is necessary to recreate the WindowManagerConnection for each test,
+ // since a new MessageLoop is created for each test.
+ WindowManagerConnection::Create(connector, identity);
}
- ~PlatformTestHelperMus() override {}
+ ~PlatformTestHelperMus() override { WindowManagerConnection::Reset(); }
private:
DISALLOW_COPY_AND_ASSIGN(PlatformTestHelperMus);
};
std::unique_ptr<PlatformTestHelper> CreatePlatformTestHelper(
- shell::Connector* connector,
- const shell::Identity& identity) {
- if (!WindowManagerConnection::Exists())
- WindowManagerConnection::Create(connector, identity);
- return base::WrapUnique(new PlatformTestHelperMus);
+ const shell::Identity& identity,
+ const base::Callback<shell::Connector*(void)>& callback) {
+ return base::WrapUnique(new PlatformTestHelperMus(callback.Run(), identity));
}
} // namespace
@@ -81,7 +79,8 @@ class ShellConnection {
// been installed first. So delay the creation until the necessary
// dependencies have been met.
PlatformTestHelper::set_factory(base::Bind(
- &CreatePlatformTestHelper, shell_connector_.get(), shell_identity_));
+ &CreatePlatformTestHelper, shell_identity_,
+ base::Bind(&ShellConnection::GetConnector, base::Unretained(this))));
}
~ShellConnection() {
@@ -95,6 +94,22 @@ class ShellConnection {
}
private:
+ shell::Connector* GetConnector() {
+ shell_connector_.reset();
+ base::WaitableEvent wait(false, false);
+ thread_.task_runner()->PostTask(FROM_HERE,
+ base::Bind(&ShellConnection::CloneConnector,
+ base::Unretained(this), &wait));
+ wait.Wait();
+ DCHECK(shell_connector_);
+ return shell_connector_.get();
+ }
+
+ void CloneConnector(base::WaitableEvent* wait) {
+ shell_connector_ = shell_connection_->connector()->Clone();
+ wait->Signal();
+ }
+
void SetUpConnections(base::WaitableEvent* wait) {
background_shell_.reset(new shell::BackgroundShell);
background_shell_->Init(nullptr);
« no previous file with comments | « no previous file | ui/views/mus/window_manager_connection.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698