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

Side by Side Diff: ui/aura/window_unittest.cc

Issue 8700013: Release aura::Desktop event handler windows on detaching an ancestor window. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use parent_ to access parent. Created 9 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 | Annotate | Revision Log
« no previous file with comments | « ui/aura/window.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "ui/aura/window.h" 5 #include "ui/aura/window.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/stringprintf.h" 9 #include "base/stringprintf.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 scoped_ptr<Window> w1(CreateTestWindowWithId(1, NULL)); 130 scoped_ptr<Window> w1(CreateTestWindowWithId(1, NULL));
131 scoped_ptr<Window> w11(CreateTestWindowWithId(11, w1.get())); 131 scoped_ptr<Window> w11(CreateTestWindowWithId(11, w1.get()));
132 scoped_ptr<Window> w111(CreateTestWindowWithId(111, w11.get())); 132 scoped_ptr<Window> w111(CreateTestWindowWithId(111, w11.get()));
133 scoped_ptr<Window> w12(CreateTestWindowWithId(12, w1.get())); 133 scoped_ptr<Window> w12(CreateTestWindowWithId(12, w1.get()));
134 134
135 EXPECT_EQ(NULL, w1->GetChildById(57)); 135 EXPECT_EQ(NULL, w1->GetChildById(57));
136 EXPECT_EQ(w12.get(), w1->GetChildById(12)); 136 EXPECT_EQ(w12.get(), w1->GetChildById(12));
137 EXPECT_EQ(w111.get(), w1->GetChildById(111)); 137 EXPECT_EQ(w111.get(), w1->GetChildById(111));
138 } 138 }
139 139
140 // Make sure that Window::Contains correctly handles children, grandchildren,
141 // and not containing NULL or parents.
142 TEST_F(WindowTest, Contains) {
143 Window parent(NULL);
144 parent.Init(ui::Layer::LAYER_HAS_NO_TEXTURE);
145 Window child1(NULL);
146 child1.Init(ui::Layer::LAYER_HAS_NO_TEXTURE);
147 Window child2(NULL);
148 child2.Init(ui::Layer::LAYER_HAS_NO_TEXTURE);
149
150 child1.SetParent(&parent);
151 child2.SetParent(&child1);
152
153 EXPECT_TRUE(parent.Contains(&parent));
154 EXPECT_TRUE(parent.Contains(&child1));
155 EXPECT_TRUE(parent.Contains(&child2));
156
157 EXPECT_FALSE(parent.Contains(NULL));
158 EXPECT_FALSE(child1.Contains(&parent));
159 EXPECT_FALSE(child2.Contains(&child1));
160 }
161
140 TEST_F(WindowTest, ConvertPointToWindow) { 162 TEST_F(WindowTest, ConvertPointToWindow) {
141 // Window::ConvertPointToWindow is mostly identical to 163 // Window::ConvertPointToWindow is mostly identical to
142 // Layer::ConvertPointToLayer, except NULL values for |source| are permitted, 164 // Layer::ConvertPointToLayer, except NULL values for |source| are permitted,
143 // in which case the function just returns. 165 // in which case the function just returns.
144 scoped_ptr<Window> w1(CreateTestWindowWithId(1, NULL)); 166 scoped_ptr<Window> w1(CreateTestWindowWithId(1, NULL));
145 gfx::Point reference_point(100, 100); 167 gfx::Point reference_point(100, 100);
146 gfx::Point test_point = reference_point; 168 gfx::Point test_point = reference_point;
147 Window::ConvertPointToWindow(NULL, w1.get(), &test_point); 169 Window::ConvertPointToWindow(NULL, w1.get(), &test_point);
148 EXPECT_EQ(reference_point, test_point); 170 EXPECT_EQ(reference_point, test_point);
149 } 171 }
(...skipping 947 matching lines...) Expand 10 before | Expand all | Expand 10 after
1097 1119
1098 w3->Activate(); 1120 w3->Activate();
1099 EXPECT_EQ(w2.get(), active()); 1121 EXPECT_EQ(w2.get(), active());
1100 1122
1101 w1->Activate(); 1123 w1->Activate();
1102 EXPECT_EQ(w1.get(), active()); 1124 EXPECT_EQ(w1.get(), active());
1103 } 1125 }
1104 1126
1105 } // namespace test 1127 } // namespace test
1106 } // namespace aura 1128 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/window.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698