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

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

Issue 782693004: Update mojo sdk to rev f6c8ec07c01deebc13178d516225fd12695c3dc2 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: hack mojo_system_impl gypi for android :| Created 6 years 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 "mojo/services/public/cpp/view_manager/view.h" 5 #include "mojo/services/public/cpp/view_manager/view.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "mojo/services/public/cpp/view_manager/lib/view_private.h" 9 #include "mojo/services/public/cpp/view_manager/lib/view_private.h"
10 #include "mojo/services/public/cpp/view_manager/util.h" 10 #include "mojo/services/public/cpp/view_manager/util.h"
(...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after
688 EXPECT_EQ("view=0,1 phase=changed visibility=false", changes[1]); 688 EXPECT_EQ("view=0,1 phase=changed visibility=false", changes[1]);
689 } 689 }
690 { 690 {
691 // Set visible to existing value and verify no notifications. 691 // Set visible to existing value and verify no notifications.
692 VisibilityChangeObserver observer(&v1); 692 VisibilityChangeObserver observer(&v1);
693 v1.SetVisible(false); 693 v1.SetVisible(false);
694 EXPECT_TRUE(observer.GetAndClearChanges().empty()); 694 EXPECT_TRUE(observer.GetAndClearChanges().empty());
695 } 695 }
696 } 696 }
697 697
698 TEST_F(ViewObserverTest, SetVisibleParent) {
699 TestView parent;
700 ViewPrivate(&parent).set_id(1);
701 TestView child;
702 ViewPrivate(&child).set_id(2);
703 parent.AddChild(&child);
704 EXPECT_TRUE(parent.visible());
705 EXPECT_TRUE(child.visible());
706 {
707 // Change visibility from true to false and make sure we get notifications
708 // on the parent.
709 VisibilityChangeObserver observer(&parent);
710 child.SetVisible(false);
711
712 Changes changes = observer.GetAndClearChanges();
713 ASSERT_EQ(1U, changes.size());
714 EXPECT_EQ("view=0,2 phase=changed visibility=false", changes[0]);
715 }
716 }
717
718 TEST_F(ViewObserverTest, SetVisibleChild) {
719 TestView parent;
720 ViewPrivate(&parent).set_id(1);
721 TestView child;
722 ViewPrivate(&child).set_id(2);
723 parent.AddChild(&child);
724 EXPECT_TRUE(parent.visible());
725 EXPECT_TRUE(child.visible());
726 {
727 // Change visibility from true to false and make sure we get notifications
728 // on the child.
729 VisibilityChangeObserver observer(&child);
730 parent.SetVisible(false);
731
732 Changes changes = observer.GetAndClearChanges();
733 ASSERT_EQ(1U, changes.size());
734 EXPECT_EQ("view=0,1 phase=changed visibility=false", changes[0]);
735 }
736 }
737
698 namespace { 738 namespace {
699 739
700 class SharedPropertyChangeObserver : public ViewObserver { 740 class SharedPropertyChangeObserver : public ViewObserver {
701 public: 741 public:
702 explicit SharedPropertyChangeObserver(View* view) : view_(view) { 742 explicit SharedPropertyChangeObserver(View* view) : view_(view) {
703 view_->AddObserver(this); 743 view_->AddObserver(this);
704 } 744 }
705 virtual ~SharedPropertyChangeObserver() { view_->RemoveObserver(this); } 745 virtual ~SharedPropertyChangeObserver() { view_->RemoveObserver(this); }
706 746
707 Changes GetAndClearChanges() { 747 Changes GetAndClearChanges() {
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
835 EXPECT_EQ(PropertyChangeInfo(&prop, -2), o.PropertyChangeInfoAndClear()); 875 EXPECT_EQ(PropertyChangeInfo(&prop, -2), o.PropertyChangeInfoAndClear());
836 v1.ClearLocalProperty(&prop); 876 v1.ClearLocalProperty(&prop);
837 EXPECT_EQ(PropertyChangeInfo(&prop, 3), o.PropertyChangeInfoAndClear()); 877 EXPECT_EQ(PropertyChangeInfo(&prop, 3), o.PropertyChangeInfoAndClear());
838 878
839 // Sanity check to see if |PropertyChangeInfoAndClear| really clears. 879 // Sanity check to see if |PropertyChangeInfoAndClear| really clears.
840 EXPECT_EQ(PropertyChangeInfo( 880 EXPECT_EQ(PropertyChangeInfo(
841 reinterpret_cast<const void*>(NULL), -3), o.PropertyChangeInfoAndClear()); 881 reinterpret_cast<const void*>(NULL), -3), o.PropertyChangeInfoAndClear());
842 } 882 }
843 883
844 } // namespace mojo 884 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698