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

Side by Side Diff: services/ui/ws/window_tree_client_unittest.cc

Issue 2712203002: c++ / mojo changes for 'external window mode'
Patch Set: . Created 3 years, 9 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 155
156 ASSERT_TRUE(wait_state_.get() == nullptr); 156 ASSERT_TRUE(wait_state_.get() == nullptr);
157 wait_state_ = base::MakeUnique<WaitState>(); 157 wait_state_ = base::MakeUnique<WaitState>();
158 wait_state_->change_count = count; 158 wait_state_->change_count = count;
159 wait_state_->run_loop.Run(); 159 wait_state_->run_loop.Run();
160 wait_state_.reset(); 160 wait_state_.reset();
161 } 161 }
162 162
163 uint32_t GetAndAdvanceChangeId() { return next_change_id_++; } 163 uint32_t GetAndAdvanceChangeId() { return next_change_id_++; }
164 164
165 mojo::Binding<WindowTreeClient>& binding() { return binding_; }
166
165 // Runs a nested MessageLoop until OnEmbed() has been encountered. 167 // Runs a nested MessageLoop until OnEmbed() has been encountered.
166 void WaitForOnEmbed() { 168 void WaitForOnEmbed() {
167 if (tree_) 169 if (tree_)
168 return; 170 return;
169 embed_run_loop_ = base::MakeUnique<base::RunLoop>(); 171 embed_run_loop_ = base::MakeUnique<base::RunLoop>();
170 embed_run_loop_->Run(); 172 embed_run_loop_->Run();
171 embed_run_loop_.reset(); 173 embed_run_loop_.reset();
172 } 174 }
173 175
174 bool WaitForChangeCompleted(uint32_t id) { 176 bool WaitForChangeCompleted(uint32_t id) {
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 service_manager::InterfaceRegistry* registry) override { 655 service_manager::InterfaceRegistry* registry) override {
654 registry->AddInterface(client_factory_.get()); 656 registry->AddInterface(client_factory_.get());
655 return true; 657 return true;
656 } 658 }
657 659
658 void SetUp() override { 660 void SetUp() override {
659 client_factory_ = base::MakeUnique<WindowTreeClientFactory>(); 661 client_factory_ = base::MakeUnique<WindowTreeClientFactory>();
660 662
661 WindowServerServiceTestBase::SetUp(); 663 WindowServerServiceTestBase::SetUp();
662 664
663 mojom::WindowTreeHostFactoryPtr factory; 665 wt_client1_ = base::MakeUnique<TestWindowTreeClient>();
664 connector()->BindInterface(ui::mojom::kServiceName, &factory);
665 666
666 mojom::WindowTreeClientPtr tree_client_ptr; 667 ui::mojom::WindowTreeHostFactoryRegistrarPtr host_factory_registrar;
667 wt_client1_ = base::MakeUnique<TestWindowTreeClient>(); 668 connector()->BindInterface(ui::mojom::kServiceName,
668 wt_client1_->Bind(MakeRequest(&tree_client_ptr)); 669 &host_factory_registrar);
669 670
670 factory->CreateWindowTreeHost(MakeRequest(&host_), 671 ui::mojom::WindowTreePtr window_tree;
671 std::move(tree_client_ptr)); 672 ui::mojom::WindowTreeHostFactoryPtr window_tree_host_factory;
673 host_factory_registrar->Register(
674 MakeRequest(&window_tree_host_factory), MakeRequest(&window_tree),
675 wt_client1_->binding().CreateInterfacePtrAndBind());
676
677 window_tree_host_factory->CreateWindowTreeHost(MakeRequest(&host_));
fwang 2017/02/28 08:23:53 As I see, we do not have test coverage for WindowT
672 678
673 // Next we should get an embed call on the "window manager" client. 679 // Next we should get an embed call on the "window manager" client.
674 wt_client1_->WaitForOnEmbed(); 680 wt_client1_->WaitForOnEmbed();
675 681
676 ASSERT_EQ(1u, changes1()->size()); 682 ASSERT_EQ(1u, changes1()->size());
677 EXPECT_EQ(CHANGE_TYPE_EMBED, (*changes1())[0].type); 683 EXPECT_EQ(CHANGE_TYPE_EMBED, (*changes1())[0].type);
678 // All these tests assume 1 for the client id. The only real assertion here 684 // All these tests assume 1 for the client id. The only real assertion here
679 // is the client id is not zero, but adding this as rest of code here 685 // is the client id is not zero, but adding this as rest of code here
680 // assumes 1. 686 // assumes 1.
681 ASSERT_GT((*changes1())[0].client_id, 0); 687 ASSERT_GT((*changes1())[0].client_id, 0);
(...skipping 1542 matching lines...) Expand 10 before | Expand all | Expand 10 after
2224 2230
2225 // TODO(sky): make sure coverage of what was 2231 // TODO(sky): make sure coverage of what was
2226 // WindowManagerTest.SecondEmbedRoot_InitService and 2232 // WindowManagerTest.SecondEmbedRoot_InitService and
2227 // WindowManagerTest.MultipleEmbedRootsBeforeWTHReady gets added to window 2233 // WindowManagerTest.MultipleEmbedRootsBeforeWTHReady gets added to window
2228 // manager 2234 // manager
2229 // tests. 2235 // tests.
2230 2236
2231 } // namespace test 2237 } // namespace test
2232 } // namespace ws 2238 } // namespace ws
2233 } // namespace ui 2239 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698