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

Side by Side Diff: services/ui/demo/mus_demo_unittests.cc

Issue 2715533005: Make mus_demo_unittests work with multiple root windows (Closed)
Patch Set: Pass the count to the callback. Created 3 years, 10 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/command_line.h" 6 #include "base/command_line.h"
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.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 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 13
14 namespace ui { 14 namespace ui {
15 namespace demo { 15 namespace demo {
16 16
17 namespace { 17 namespace {
18 18
19 const char kTestAppName[] = "mus_demo_unittests"; 19 const char kTestAppName[] = "mus_demo_unittests";
20 20
21 void RunCallback(bool* success, const base::Closure& callback, bool result) { 21 void RunCallback(uint64_t* root_window_count,
22 *success = result; 22 const base::Closure& callback,
23 uint64_t result) {
24 *root_window_count = result;
23 callback.Run(); 25 callback.Run();
24 } 26 }
25 27
26 class MusDemoTest : public service_manager::test::ServiceTest { 28 class MusDemoTest : public service_manager::test::ServiceTest {
27 public: 29 public:
28 MusDemoTest() : service_manager::test::ServiceTest(kTestAppName) {} 30 MusDemoTest() : service_manager::test::ServiceTest(kTestAppName) {}
29 ~MusDemoTest() override {} 31 ~MusDemoTest() override {}
30 32
31 void SetUp() override { 33 void SetUp() override {
32 base::CommandLine::ForCurrentProcess()->AppendSwitch("use-test-config"); 34 base::CommandLine::ForCurrentProcess()->AppendSwitch("use-test-config");
33 ServiceTest::SetUp(); 35 ServiceTest::SetUp();
34 } 36 }
35 37
36 private: 38 private:
37 DISALLOW_COPY_AND_ASSIGN(MusDemoTest); 39 DISALLOW_COPY_AND_ASSIGN(MusDemoTest);
38 }; 40 };
39 41
40 } // namespace 42 } // namespace
41 43
42 TEST_F(MusDemoTest, CheckMusDemoDraws) { 44 TEST_F(MusDemoTest, CheckMusDemoDraws) {
43 connector()->Connect("mus_demo"); 45 connector()->Connect("mus_demo");
44 46
45 ::ui::mojom::WindowServerTestPtr test_interface; 47 ::ui::mojom::WindowServerTestPtr test_interface;
46 connector()->BindInterface(ui::mojom::kServiceName, &test_interface); 48 connector()->BindInterface(ui::mojom::kServiceName, &test_interface);
47 49
48 base::RunLoop run_loop; 50 base::RunLoop run_loop;
49 bool success = false; 51 uint64_t root_window_count = 0;
50 // TODO(kylechar): Fix WindowServer::CreateTreeForWindowManager so that the 52 // TODO(kylechar): Fix WindowServer::CreateTreeForWindowManager so that the
51 // WindowTree has the correct name instead of an empty name. 53 // WindowTree has the correct name instead of an empty name.
52 test_interface->EnsureClientHasDrawnWindow( 54 // TODO(tonikitoo,fwang): Also fix the WindowTree name for MusDemoExternal.
55 test_interface->EnsureClientHasDrawnRootWindows(
53 "", // WindowTree name is empty. 56 "", // WindowTree name is empty.
54 base::Bind(&RunCallback, &success, run_loop.QuitClosure())); 57 base::Bind(&RunCallback, &root_window_count, run_loop.QuitClosure()));
55 run_loop.Run(); 58 run_loop.Run();
56 EXPECT_TRUE(success); 59 // TODO(tonikitoo,fwang): Test multiple windows for MusDemoExternal.
60 EXPECT_EQ(1u, root_window_count);
57 } 61 }
58 62
59 } // namespace demo 63 } // namespace demo
60 } // namespace ui 64 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698