| OLD | NEW |
| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
| 7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
| 8 #include "mash/quick_launch/public/interfaces/constants.mojom.h" | 8 #include "mash/quick_launch/public/interfaces/constants.mojom.h" |
| 9 #include "services/service_manager/public/cpp/service_test.h" | 9 #include "services/service_manager/public/cpp/service_test.h" |
| 10 #include "services/ui/public/interfaces/constants.mojom.h" | 10 #include "services/ui/public/interfaces/constants.mojom.h" |
| 11 #include "services/ui/public/interfaces/window_server_test.mojom.h" | 11 #include "services/ui/public/interfaces/window_server_test.mojom.h" |
| 12 | 12 |
| 13 namespace ash { | 13 namespace ash { |
| 14 namespace mus { | 14 namespace mus { |
| 15 | 15 |
| 16 void RunCallback(bool* success, const base::Closure& callback, bool result) { | 16 void RunCallback(uint64_t* root_window_count, |
| 17 *success = result; | 17 const base::Closure& callback, |
| 18 uint64_t result) { |
| 19 *root_window_count = result; |
| 18 callback.Run(); | 20 callback.Run(); |
| 19 } | 21 } |
| 20 | 22 |
| 21 class AppLaunchTest : public service_manager::test::ServiceTest { | 23 class AppLaunchTest : public service_manager::test::ServiceTest { |
| 22 public: | 24 public: |
| 23 AppLaunchTest() : ServiceTest("mash_unittests") {} | 25 AppLaunchTest() : ServiceTest("mash_unittests") {} |
| 24 ~AppLaunchTest() override {} | 26 ~AppLaunchTest() override {} |
| 25 | 27 |
| 26 private: | 28 private: |
| 27 void SetUp() override { | 29 void SetUp() override { |
| 28 base::CommandLine::ForCurrentProcess()->AppendSwitch("use-test-config"); | 30 base::CommandLine::ForCurrentProcess()->AppendSwitch("use-test-config"); |
| 29 ServiceTest::SetUp(); | 31 ServiceTest::SetUp(); |
| 30 } | 32 } |
| 31 | 33 |
| 32 DISALLOW_COPY_AND_ASSIGN(AppLaunchTest); | 34 DISALLOW_COPY_AND_ASSIGN(AppLaunchTest); |
| 33 }; | 35 }; |
| 34 | 36 |
| 35 TEST_F(AppLaunchTest, TestQuickLaunch) { | 37 TEST_F(AppLaunchTest, TestQuickLaunch) { |
| 36 connector()->Connect("ash"); | 38 connector()->Connect("ash"); |
| 37 connector()->Connect(mash::quick_launch::mojom::kServiceName); | 39 connector()->Connect(mash::quick_launch::mojom::kServiceName); |
| 38 | 40 |
| 39 ui::mojom::WindowServerTestPtr test_interface; | 41 ui::mojom::WindowServerTestPtr test_interface; |
| 40 connector()->BindInterface(ui::mojom::kServiceName, &test_interface); | 42 connector()->BindInterface(ui::mojom::kServiceName, &test_interface); |
| 41 | 43 |
| 42 base::RunLoop run_loop; | 44 base::RunLoop run_loop; |
| 43 bool success = false; | 45 uint64_t root_window_count = 0; |
| 44 test_interface->EnsureClientHasDrawnWindow( | 46 test_interface->EnsureClientHasDrawnRootWindows( |
| 45 mash::quick_launch::mojom::kServiceName, | 47 mash::quick_launch::mojom::kServiceName, |
| 46 base::Bind(&RunCallback, &success, run_loop.QuitClosure())); | 48 base::Bind(&RunCallback, &root_window_count, run_loop.QuitClosure())); |
| 47 run_loop.Run(); | 49 run_loop.Run(); |
| 48 EXPECT_TRUE(success); | 50 EXPECT_EQ(1u, root_window_count); |
| 49 } | 51 } |
| 50 | 52 |
| 51 } // namespace mus | 53 } // namespace mus |
| 52 } // namespace ash | 54 } // namespace ash |
| OLD | NEW |