| OLD | NEW |
| 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 Loading... |
| 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 |
| OLD | NEW |