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

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

Issue 9289036: aura: Add Layer::LAYER_SOLID_COLOR to compositor. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: update WorkspaceManagerTest Created 8 years, 10 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
« no previous file with comments | « ui/aura/test/test_windows.cc ('k') | ui/gfx/compositor/layer.h » ('j') | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 175
176 EXPECT_EQ(NULL, w1->GetChildById(57)); 176 EXPECT_EQ(NULL, w1->GetChildById(57));
177 EXPECT_EQ(w12.get(), w1->GetChildById(12)); 177 EXPECT_EQ(w12.get(), w1->GetChildById(12));
178 EXPECT_EQ(w111.get(), w1->GetChildById(111)); 178 EXPECT_EQ(w111.get(), w1->GetChildById(111));
179 } 179 }
180 180
181 // Make sure that Window::Contains correctly handles children, grandchildren, 181 // Make sure that Window::Contains correctly handles children, grandchildren,
182 // and not containing NULL or parents. 182 // and not containing NULL or parents.
183 TEST_F(WindowTest, Contains) { 183 TEST_F(WindowTest, Contains) {
184 Window parent(NULL); 184 Window parent(NULL);
185 parent.Init(ui::Layer::LAYER_HAS_NO_TEXTURE); 185 parent.Init(ui::Layer::LAYER_NOT_DRAWN);
186 Window child1(NULL); 186 Window child1(NULL);
187 child1.Init(ui::Layer::LAYER_HAS_NO_TEXTURE); 187 child1.Init(ui::Layer::LAYER_NOT_DRAWN);
188 Window child2(NULL); 188 Window child2(NULL);
189 child2.Init(ui::Layer::LAYER_HAS_NO_TEXTURE); 189 child2.Init(ui::Layer::LAYER_NOT_DRAWN);
190 190
191 child1.SetParent(&parent); 191 child1.SetParent(&parent);
192 child2.SetParent(&child1); 192 child2.SetParent(&child1);
193 193
194 EXPECT_TRUE(parent.Contains(&parent)); 194 EXPECT_TRUE(parent.Contains(&parent));
195 EXPECT_TRUE(parent.Contains(&child1)); 195 EXPECT_TRUE(parent.Contains(&child1));
196 EXPECT_TRUE(parent.Contains(&child2)); 196 EXPECT_TRUE(parent.Contains(&child2));
197 197
198 EXPECT_FALSE(parent.Contains(NULL)); 198 EXPECT_FALSE(parent.Contains(NULL));
199 EXPECT_FALSE(child1.Contains(&parent)); 199 EXPECT_FALSE(child1.Contains(&parent));
200 EXPECT_FALSE(child2.Contains(&child1)); 200 EXPECT_FALSE(child2.Contains(&child1));
201 } 201 }
202 202
203 TEST_F(WindowTest, ConvertPointToWindow) { 203 TEST_F(WindowTest, ConvertPointToWindow) {
204 // Window::ConvertPointToWindow is mostly identical to 204 // Window::ConvertPointToWindow is mostly identical to
205 // Layer::ConvertPointToLayer, except NULL values for |source| are permitted, 205 // Layer::ConvertPointToLayer, except NULL values for |source| are permitted,
206 // in which case the function just returns. 206 // in which case the function just returns.
207 scoped_ptr<Window> w1(CreateTestWindowWithId(1, NULL)); 207 scoped_ptr<Window> w1(CreateTestWindowWithId(1, NULL));
208 gfx::Point reference_point(100, 100); 208 gfx::Point reference_point(100, 100);
209 gfx::Point test_point = reference_point; 209 gfx::Point test_point = reference_point;
210 Window::ConvertPointToWindow(NULL, w1.get(), &test_point); 210 Window::ConvertPointToWindow(NULL, w1.get(), &test_point);
211 EXPECT_EQ(reference_point, test_point); 211 EXPECT_EQ(reference_point, test_point);
212 } 212 }
213 213
214 TEST_F(WindowTest, HitTest) { 214 TEST_F(WindowTest, HitTest) {
215 Window w1(new ColorTestWindowDelegate(SK_ColorWHITE)); 215 Window w1(new ColorTestWindowDelegate(SK_ColorWHITE));
216 w1.set_id(1); 216 w1.set_id(1);
217 w1.Init(ui::Layer::LAYER_HAS_TEXTURE); 217 w1.Init(ui::Layer::LAYER_TEXTURED);
218 w1.SetBounds(gfx::Rect(10, 10, 50, 50)); 218 w1.SetBounds(gfx::Rect(10, 10, 50, 50));
219 w1.Show(); 219 w1.Show();
220 w1.SetParent(NULL); 220 w1.SetParent(NULL);
221 221
222 // Points are in the Window's coordinates. 222 // Points are in the Window's coordinates.
223 EXPECT_TRUE(w1.HitTest(gfx::Point(1, 1))); 223 EXPECT_TRUE(w1.HitTest(gfx::Point(1, 1)));
224 EXPECT_FALSE(w1.HitTest(gfx::Point(-1, -1))); 224 EXPECT_FALSE(w1.HitTest(gfx::Point(-1, -1)));
225 225
226 // TODO(beng): clip Window to parent. 226 // TODO(beng): clip Window to parent.
227 } 227 }
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 CreateTestWindowWithDelegate(&parent_delegate, 0, gfx::Rect(), NULL)); 335 CreateTestWindowWithDelegate(&parent_delegate, 0, gfx::Rect(), NULL));
336 scoped_ptr<Window> child(CreateTestWindowWithDelegate(&child_delegate, 0, 336 scoped_ptr<Window> child(CreateTestWindowWithDelegate(&child_delegate, 0,
337 gfx::Rect(), parent.get())); 337 gfx::Rect(), parent.get()));
338 child_delegate.set_window(child.get()); 338 child_delegate.set_window(child.get());
339 } 339 }
340 } 340 }
341 341
342 // Make sure StackChildAtTop moves both the window and layer to the front. 342 // Make sure StackChildAtTop moves both the window and layer to the front.
343 TEST_F(WindowTest, StackChildAtTop) { 343 TEST_F(WindowTest, StackChildAtTop) {
344 Window parent(NULL); 344 Window parent(NULL);
345 parent.Init(ui::Layer::LAYER_HAS_NO_TEXTURE); 345 parent.Init(ui::Layer::LAYER_NOT_DRAWN);
346 Window child1(NULL); 346 Window child1(NULL);
347 child1.Init(ui::Layer::LAYER_HAS_NO_TEXTURE); 347 child1.Init(ui::Layer::LAYER_NOT_DRAWN);
348 Window child2(NULL); 348 Window child2(NULL);
349 child2.Init(ui::Layer::LAYER_HAS_NO_TEXTURE); 349 child2.Init(ui::Layer::LAYER_NOT_DRAWN);
350 350
351 child1.SetParent(&parent); 351 child1.SetParent(&parent);
352 child2.SetParent(&parent); 352 child2.SetParent(&parent);
353 ASSERT_EQ(2u, parent.children().size()); 353 ASSERT_EQ(2u, parent.children().size());
354 EXPECT_EQ(&child1, parent.children()[0]); 354 EXPECT_EQ(&child1, parent.children()[0]);
355 EXPECT_EQ(&child2, parent.children()[1]); 355 EXPECT_EQ(&child2, parent.children()[1]);
356 ASSERT_EQ(2u, parent.layer()->children().size()); 356 ASSERT_EQ(2u, parent.layer()->children().size());
357 EXPECT_EQ(child1.layer(), parent.layer()->children()[0]); 357 EXPECT_EQ(child1.layer(), parent.layer()->children()[0]);
358 EXPECT_EQ(child2.layer(), parent.layer()->children()[1]); 358 EXPECT_EQ(child2.layer(), parent.layer()->children()[1]);
359 359
360 parent.StackChildAtTop(&child1); 360 parent.StackChildAtTop(&child1);
361 ASSERT_EQ(2u, parent.children().size()); 361 ASSERT_EQ(2u, parent.children().size());
362 EXPECT_EQ(&child1, parent.children()[1]); 362 EXPECT_EQ(&child1, parent.children()[1]);
363 EXPECT_EQ(&child2, parent.children()[0]); 363 EXPECT_EQ(&child2, parent.children()[0]);
364 ASSERT_EQ(2u, parent.layer()->children().size()); 364 ASSERT_EQ(2u, parent.layer()->children().size());
365 EXPECT_EQ(child1.layer(), parent.layer()->children()[1]); 365 EXPECT_EQ(child1.layer(), parent.layer()->children()[1]);
366 EXPECT_EQ(child2.layer(), parent.layer()->children()[0]); 366 EXPECT_EQ(child2.layer(), parent.layer()->children()[0]);
367 } 367 }
368 368
369 // Various assertions for StackChildAbove. 369 // Various assertions for StackChildAbove.
370 TEST_F(WindowTest, StackChildAbove) { 370 TEST_F(WindowTest, StackChildAbove) {
371 Window parent(NULL); 371 Window parent(NULL);
372 parent.Init(ui::Layer::LAYER_HAS_NO_TEXTURE); 372 parent.Init(ui::Layer::LAYER_NOT_DRAWN);
373 Window child1(NULL); 373 Window child1(NULL);
374 child1.Init(ui::Layer::LAYER_HAS_NO_TEXTURE); 374 child1.Init(ui::Layer::LAYER_NOT_DRAWN);
375 Window child2(NULL); 375 Window child2(NULL);
376 child2.Init(ui::Layer::LAYER_HAS_NO_TEXTURE); 376 child2.Init(ui::Layer::LAYER_NOT_DRAWN);
377 Window child3(NULL); 377 Window child3(NULL);
378 child3.Init(ui::Layer::LAYER_HAS_NO_TEXTURE); 378 child3.Init(ui::Layer::LAYER_NOT_DRAWN);
379 379
380 child1.SetParent(&parent); 380 child1.SetParent(&parent);
381 child2.SetParent(&parent); 381 child2.SetParent(&parent);
382 382
383 // Move 1 in front of 2. 383 // Move 1 in front of 2.
384 parent.StackChildAbove(&child1, &child2); 384 parent.StackChildAbove(&child1, &child2);
385 ASSERT_EQ(2u, parent.children().size()); 385 ASSERT_EQ(2u, parent.children().size());
386 EXPECT_EQ(&child2, parent.children()[0]); 386 EXPECT_EQ(&child2, parent.children()[0]);
387 EXPECT_EQ(&child1, parent.children()[1]); 387 EXPECT_EQ(&child1, parent.children()[1]);
388 ASSERT_EQ(2u, parent.layer()->children().size()); 388 ASSERT_EQ(2u, parent.layer()->children().size());
(...skipping 825 matching lines...) Expand 10 before | Expand all | Expand 10 after
1214 window->Show(); 1214 window->Show();
1215 1215
1216 client.set_ignore_visibility_changes(true); 1216 client.set_ignore_visibility_changes(true);
1217 window->Hide(); 1217 window->Hide();
1218 EXPECT_FALSE(window->IsVisible()); 1218 EXPECT_FALSE(window->IsVisible());
1219 EXPECT_TRUE(window->layer()->visible()); 1219 EXPECT_TRUE(window->layer()->visible());
1220 } 1220 }
1221 1221
1222 } // namespace test 1222 } // namespace test
1223 } // namespace aura 1223 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/test/test_windows.cc ('k') | ui/gfx/compositor/layer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698