diff options
author | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-27 23:49:52 +0000 |
---|---|---|
committer | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-27 23:49:52 +0000 |
commit | 44e50eb0e4b1678778945a4bd47c65b6fe32a37b (patch) | |
tree | a3446ee24c638999025c6e40f4a4984af9d07109 /views | |
parent | a4770b63fa4b227ef3895c0368be9c491e8f054d (diff) | |
download | chromium_src-44e50eb0e4b1678778945a4bd47c65b6fe32a37b.zip chromium_src-44e50eb0e4b1678778945a4bd47c65b6fe32a37b.tar.gz chromium_src-44e50eb0e4b1678778945a4bd47c65b6fe32a37b.tar.bz2 |
views: Add unittests for View::GetViewByID() method.
BUG=None
TEST=views_unittests --gtest_filter=ViewTest.GetViewByID
R=sky@chromium.org
Review URL: http://codereview.chromium.org/7272003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@90679 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r-- | views/view_unittest.cc | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/views/view_unittest.cc b/views/view_unittest.cc index 729b0c2..29b312f 100644 --- a/views/view_unittest.cc +++ b/views/view_unittest.cc @@ -2208,6 +2208,44 @@ TEST_F(ViewTest, ReorderChildren) { ASSERT_EQ(foo1, foo3->GetNextFocusableView()); } +// Verifies that GetViewByID returns the correctly child view from the specified +// ID. +// The tree looks like this: +// v1 +// +-- v2 +// +-- v3 +// +-- v4 +TEST_F(ViewTest, GetViewByID) { + View v1; + const int kV1ID = 1; + v1.set_id(kV1ID); + + View v2; + const int kV2ID = 2; + v2.set_id(kV2ID); + + View v3; + const int kV3ID = 3; + v3.set_id(kV3ID); + + View v4; + const int kV4ID = 4; + v4.set_id(kV4ID); + + const int kV5ID = 5; + + v1.AddChildView(&v2); + v2.AddChildView(&v3); + v2.AddChildView(&v4); + + EXPECT_EQ(&v1, v1.GetViewByID(kV1ID)); + EXPECT_EQ(&v2, v1.GetViewByID(kV2ID)); + EXPECT_EQ(&v4, v1.GetViewByID(kV4ID)); + + EXPECT_EQ(NULL, v1.GetViewByID(kV5ID)); // No V5 exists. + EXPECT_EQ(NULL, v2.GetViewByID(kV1ID)); // It can get only from child views. +} + //////////////////////////////////////////////////////////////////////////////// // Layers //////////////////////////////////////////////////////////////////////////////// |