| Index: mojo/services/public/cpp/view_manager/tests/view_manager_unittest.cc
|
| diff --git a/mojo/services/public/cpp/view_manager/tests/view_manager_unittest.cc b/mojo/services/public/cpp/view_manager/tests/view_manager_unittest.cc
|
| index f86820a4d6440cac66f8508ea920e2082cadb0b2..567d3cf55f013172552656973ae41ca8b127853f 100644
|
| --- a/mojo/services/public/cpp/view_manager/tests/view_manager_unittest.cc
|
| +++ b/mojo/services/public/cpp/view_manager/tests/view_manager_unittest.cc
|
| @@ -18,6 +18,7 @@
|
|
|
| namespace mojo {
|
| namespace view_manager {
|
| +namespace {
|
|
|
| base::RunLoop* current_run_loop = NULL;
|
|
|
| @@ -72,6 +73,36 @@ void WaitForActiveViewToChange(ViewTreeNode* node) {
|
| node->RemoveObserver(&observer);
|
| }
|
|
|
| +class BoundsChangeObserver : public ViewTreeNodeObserver {
|
| + public:
|
| + explicit BoundsChangeObserver(ViewTreeNode* node) : node_(node) {}
|
| + virtual ~BoundsChangeObserver() {}
|
| +
|
| + private:
|
| + // Overridden from ViewTreeNodeObserver:
|
| + virtual void OnNodeBoundsChange(ViewTreeNode* node,
|
| + const gfx::Rect& old_bounds,
|
| + const gfx::Rect& new_bounds,
|
| + DispositionChangePhase phase) OVERRIDE {
|
| + DCHECK_EQ(node, node_);
|
| + if (phase != ViewTreeNodeObserver::DISPOSITION_CHANGED)
|
| + return;
|
| + QuitRunLoop();
|
| + }
|
| +
|
| + ViewTreeNode* node_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(BoundsChangeObserver);
|
| +};
|
| +
|
| +// Wait until the bounds of the supplied node change.
|
| +void WaitForBoundsToChange(ViewTreeNode* node) {
|
| + BoundsChangeObserver observer(node);
|
| + node->AddObserver(&observer);
|
| + DoRunLoop();
|
| + node->RemoveObserver(&observer);
|
| +}
|
| +
|
| // Spins a runloop until the tree beginning at |root| has |tree_size| nodes
|
| // (including |root|).
|
| class TreeSizeMatchesObserver : public ViewTreeNodeObserver {
|
| @@ -185,6 +216,8 @@ void WaitForDestruction(ViewManager* view_manager,
|
| DoRunLoop();
|
| }
|
|
|
| +} // namespace
|
| +
|
| // ViewManager -----------------------------------------------------------------
|
|
|
| // These tests model synchronization of two peer connections to the view manager
|
| @@ -528,5 +561,19 @@ TEST_F(ViewManagerTest, MapSubtreeOnAttach) {
|
| EXPECT_EQ(view11_2, node11_2->active_view());
|
| }
|
|
|
| +// Verifies that bounds changes applied to a node hierarchy in one connection
|
| +// are reflected to another.
|
| +TEST_F(ViewManagerTest, SetBounds) {
|
| + ViewTreeNode* node1 = CreateNodeInParent(view_manager_1()->tree());
|
| + WaitForTreeSizeToMatch(view_manager_2()->tree(), 2);
|
| +
|
| + ViewTreeNode* node1_2 = view_manager_2()->GetNodeById(node1->id());
|
| + EXPECT_EQ(node1->bounds(), node1_2->bounds());
|
| +
|
| + node1->SetBounds(gfx::Rect(0, 0, 100, 100));
|
| + WaitForBoundsToChange(node1_2);
|
| + EXPECT_EQ(node1->bounds(), node1_2->bounds());
|
| +}
|
| +
|
| } // namespace view_manager
|
| } // namespace mojo
|
|
|