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

Side by Side Diff: components/exo/wayland/server_unittest.cc

Issue 2056493002: clang-tidy WaitableEvent refactor (ChromeOS side) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
« no previous file with comments | « chromeos/system/statistics_provider.cc ('k') | no next file » | 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 "components/exo/wayland/server.h" 5 #include "components/exo/wayland/server.h"
6 6
7 #include <wayland-client-core.h> 7 #include <wayland-client-core.h>
8 8
9 #include <memory> 9 #include <memory>
10 10
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 63
64 std::string socket_name = GetUniqueSocketName(); 64 std::string socket_name = GetUniqueSocketName();
65 bool rv = server->AddSocket(socket_name); 65 bool rv = server->AddSocket(socket_name);
66 EXPECT_TRUE(rv); 66 EXPECT_TRUE(rv);
67 67
68 base::Thread client("client-" + socket_name); 68 base::Thread client("client-" + socket_name);
69 ASSERT_TRUE(client.Start()); 69 ASSERT_TRUE(client.Start());
70 70
71 // Post a task that connects server on the created thread. 71 // Post a task that connects server on the created thread.
72 bool connected_to_server = false; 72 bool connected_to_server = false;
73 base::WaitableEvent event(false, false); 73 base::WaitableEvent event(base::WaitableEvent::ResetPolicy::AUTOMATIC,
74 base::WaitableEvent::InitialState::NOT_SIGNALED);
74 client.task_runner()->PostTask( 75 client.task_runner()->PostTask(
75 FROM_HERE, 76 FROM_HERE,
76 base::Bind(&ConnectToServer, socket_name, &connected_to_server, &event)); 77 base::Bind(&ConnectToServer, socket_name, &connected_to_server, &event));
77 78
78 // Call Dispatch() with a 5 second timeout. 79 // Call Dispatch() with a 5 second timeout.
79 server->Dispatch(base::TimeDelta::FromSeconds(5)); 80 server->Dispatch(base::TimeDelta::FromSeconds(5));
80 81
81 // Check if client thread managed to connect to server. 82 // Check if client thread managed to connect to server.
82 event.Wait(); 83 event.Wait();
83 EXPECT_TRUE(connected_to_server); 84 EXPECT_TRUE(connected_to_server);
84 } 85 }
85 86
86 TEST(ServerTest, Flush) { 87 TEST(ServerTest, Flush) {
87 std::unique_ptr<Display> display(new Display); 88 std::unique_ptr<Display> display(new Display);
88 std::unique_ptr<Server> server(new Server(display.get())); 89 std::unique_ptr<Server> server(new Server(display.get()));
89 90
90 bool rv = server->AddSocket(GetUniqueSocketName()); 91 bool rv = server->AddSocket(GetUniqueSocketName());
91 EXPECT_TRUE(rv); 92 EXPECT_TRUE(rv);
92 93
93 // Just call Flush to check that it doesn't have any bad side-effects. 94 // Just call Flush to check that it doesn't have any bad side-effects.
94 server->Flush(); 95 server->Flush();
95 } 96 }
96 97
97 } // namespace 98 } // namespace
98 } // namespace wayland 99 } // namespace wayland
99 } // namespace exo 100 } // namespace exo
OLDNEW
« no previous file with comments | « chromeos/system/statistics_provider.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698