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

Side by Side Diff: mojo/services/public/cpp/view_manager/tests/view_manager_unittest.cc

Issue 303163005: Embedding demo in View manager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 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 | Annotate | Revision Log
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 "mojo/services/public/cpp/view_manager/view_manager.h" 5 #include "mojo/services/public/cpp/view_manager/view_manager.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "mojo/services/public/cpp/view_manager/lib/view_manager_private.h" 9 #include "mojo/services/public/cpp/view_manager/lib/view_manager_private.h"
10 #include "mojo/services/public/cpp/view_manager/lib/view_manager_synchronizer.h" 10 #include "mojo/services/public/cpp/view_manager/lib/view_manager_synchronizer.h"
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 // ViewManager ----------------------------------------------------------------- 251 // ViewManager -----------------------------------------------------------------
252 252
253 // These tests model synchronization of two peer connections to the view manager 253 // These tests model synchronization of two peer connections to the view manager
254 // service, that are given access to some root node. 254 // service, that are given access to some root node.
255 255
256 class ViewManagerTest : public testing::Test { 256 class ViewManagerTest : public testing::Test {
257 public: 257 public:
258 ViewManagerTest() : commit_count_(0) {} 258 ViewManagerTest() : commit_count_(0) {}
259 259
260 protected: 260 protected:
261 ViewManager* view_manager_1() { return view_manager_1_.get(); } 261 ViewManager* view_manager_1() { return view_manager_1_; }
262 ViewManager* view_manager_2() { return view_manager_2_.get(); } 262 ViewManager* view_manager_2() { return view_manager_2_; }
263 263
264 ViewTreeNode* CreateNodeInParent(ViewTreeNode* parent) { 264 ViewTreeNode* CreateNodeInParent(ViewTreeNode* parent) {
265 ViewManager* parent_manager = ViewTreeNodePrivate(parent).view_manager(); 265 ViewManager* parent_manager = ViewTreeNodePrivate(parent).view_manager();
266 ViewTreeNode* node = ViewTreeNode::Create(parent_manager); 266 ViewTreeNode* node = ViewTreeNode::Create(parent_manager);
267 parent->AddChild(node); 267 parent->AddChild(node);
268 return node; 268 return node;
269 } 269 }
270 270
271 void DestroyViewManager1() { 271 void DestroyViewManager1() {
272 view_manager_1_.reset(); 272 // view_manager_1_.reset();
273 } 273 }
274 274
275 private: 275 private:
276 // Overridden from testing::Test: 276 // Overridden from testing::Test:
277 virtual void SetUp() OVERRIDE { 277 virtual void SetUp() OVERRIDE {
278 test_helper_.Init(); 278 test_helper_.Init();
279 view_manager_1_.reset(new ViewManager(test_helper_.service_provider()));
280 view_manager_2_.reset(new ViewManager(test_helper_.service_provider()));
281 view_manager_1_->Init();
282 view_manager_2_->Init();
283 } 279 }
284 280
285 base::MessageLoop loop_; 281 base::MessageLoop loop_;
286 shell::ShellTestHelper test_helper_; 282 shell::ShellTestHelper test_helper_;
287 scoped_ptr<ViewManager> view_manager_1_; 283 ViewManager* view_manager_1_;
288 scoped_ptr<ViewManager> view_manager_2_; 284 ViewManager* view_manager_2_;
289 int commit_count_; 285 int commit_count_;
290 286
291 DISALLOW_COPY_AND_ASSIGN(ViewManagerTest); 287 DISALLOW_COPY_AND_ASSIGN(ViewManagerTest);
292 }; 288 };
293 289
294 // Base class for helpers that quit the current runloop after a specific tree 290 // Base class for helpers that quit the current runloop after a specific tree
295 // change is observed by a view manager. 291 // change is observed by a view manager.
296 class TreeObserverBase : public ViewTreeNodeObserver { 292 class TreeObserverBase : public ViewTreeNodeObserver {
297 public: 293 public:
298 explicit TreeObserverBase(ViewManager* view_manager) 294 explicit TreeObserverBase(ViewManager* view_manager)
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 // Node should not have been destroyed. 630 // Node should not have been destroyed.
635 EXPECT_TRUE(tracker2.is_valid()); 631 EXPECT_TRUE(tracker2.is_valid());
636 632
637 NodeTracker tracker1(node1); 633 NodeTracker tracker1(node1);
638 node1->Destroy(); 634 node1->Destroy();
639 EXPECT_FALSE(tracker1.is_valid()); 635 EXPECT_FALSE(tracker1.is_valid());
640 } 636 }
641 637
642 } // namespace view_manager 638 } // namespace view_manager
643 } // namespace mojo 639 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698