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

Side by Side Diff: ui/views/view_unittest.cc

Issue 11145005: Migrate ui::Transform to gfx::Transform (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Hopefully should work this time Created 8 years, 2 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
« no previous file with comments | « ui/views/view.cc ('k') | ui/views/widget/widget.cc » ('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 <map> 5 #include <map>
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/rand_util.h" 8 #include "base/rand_util.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 944 matching lines...) Expand 10 before | Expand all | Expand 10 after
955 View::ConvertPointToTarget(view->GetWidget()->GetRootView(), view, &tmp); 955 View::ConvertPointToTarget(view->GetWidget()->GetRootView(), view, &tmp);
956 return tmp; 956 return tmp;
957 } 957 }
958 958
959 gfx::Rect ConvertRectToView(View* view, const gfx::Rect& r) { 959 gfx::Rect ConvertRectToView(View* view, const gfx::Rect& r) {
960 gfx::Rect tmp(r); 960 gfx::Rect tmp(r);
961 tmp.set_origin(ConvertPointToView(view, r.origin())); 961 tmp.set_origin(ConvertPointToView(view, r.origin()));
962 return tmp; 962 return tmp;
963 } 963 }
964 964
965 void RotateCounterclockwise(ui::Transform* transform) { 965 void RotateCounterclockwise(gfx::Transform* transform) {
966 transform->matrix().set3x3(0, -1, 0, 966 transform->matrix().set3x3(0, -1, 0,
967 1, 0, 0, 967 1, 0, 0,
968 0, 0, 1); 968 0, 0, 1);
969 } 969 }
970 970
971 void RotateClockwise(ui::Transform* transform) { 971 void RotateClockwise(gfx::Transform* transform) {
972 transform->matrix().set3x3( 0, 1, 0, 972 transform->matrix().set3x3( 0, 1, 0,
973 -1, 0, 0, 973 -1, 0, 0,
974 0, 0, 1); 974 0, 0, 1);
975 } 975 }
976 976
977 } // namespace 977 } // namespace
978 978
979 TEST_F(ViewTest, HitTestMasks) { 979 TEST_F(ViewTest, HitTestMasks) {
980 Widget* widget = new Widget; 980 Widget* widget = new Widget;
981 widget->Init(Widget::InitParams(Widget::InitParams::TYPE_POPUP)); 981 widget->Init(Widget::InitParams(Widget::InitParams::TYPE_POPUP));
(...skipping 1059 matching lines...) Expand 10 before | Expand all | Expand 10 after
2041 root->AddChildView(v1); 2041 root->AddChildView(v1);
2042 v1->AddChildView(v2); 2042 v1->AddChildView(v2);
2043 2043
2044 // At this moment, |v2| occupies (100, 100) to (300, 200) in |root|. 2044 // At this moment, |v2| occupies (100, 100) to (300, 200) in |root|.
2045 v1->ClearScheduledPaintRect(); 2045 v1->ClearScheduledPaintRect();
2046 v2->SchedulePaint(); 2046 v2->SchedulePaint();
2047 2047
2048 EXPECT_EQ(gfx::Rect(100, 100, 200, 100), v1->scheduled_paint_rect()); 2048 EXPECT_EQ(gfx::Rect(100, 100, 200, 100), v1->scheduled_paint_rect());
2049 2049
2050 // Rotate |v1| counter-clockwise. 2050 // Rotate |v1| counter-clockwise.
2051 ui::Transform transform; 2051 gfx::Transform transform;
2052 RotateCounterclockwise(&transform); 2052 RotateCounterclockwise(&transform);
2053 transform.SetTranslateY(500.0f); 2053 transform.SetTranslateY(500.0f);
2054 v1->SetTransform(transform); 2054 v1->SetTransform(transform);
2055 2055
2056 // |v2| now occupies (100, 200) to (200, 400) in |root|. 2056 // |v2| now occupies (100, 200) to (200, 400) in |root|.
2057 2057
2058 v1->ClearScheduledPaintRect(); 2058 v1->ClearScheduledPaintRect();
2059 v2->SchedulePaint(); 2059 v2->SchedulePaint();
2060 2060
2061 EXPECT_EQ(gfx::Rect(100, 200, 100, 200), v1->scheduled_paint_rect()); 2061 EXPECT_EQ(gfx::Rect(100, 200, 100, 200), v1->scheduled_paint_rect());
(...skipping 13 matching lines...) Expand all
2075 params.bounds = gfx::Rect(50, 50, 650, 650); 2075 params.bounds = gfx::Rect(50, 50, 650, 650);
2076 widget->Init(params); 2076 widget->Init(params);
2077 View* root = widget->GetRootView(); 2077 View* root = widget->GetRootView();
2078 2078
2079 root->AddChildView(v1); 2079 root->AddChildView(v1);
2080 v1->AddChildView(v2); 2080 v1->AddChildView(v2);
2081 2081
2082 // At this moment, |v2| occupies (100, 100) to (300, 200) in |root|. 2082 // At this moment, |v2| occupies (100, 100) to (300, 200) in |root|.
2083 2083
2084 // Rotate |v1| counter-clockwise. 2084 // Rotate |v1| counter-clockwise.
2085 ui::Transform transform(v1->GetTransform()); 2085 gfx::Transform transform(v1->GetTransform());
2086 RotateCounterclockwise(&transform); 2086 RotateCounterclockwise(&transform);
2087 transform.SetTranslateY(500.0f); 2087 transform.SetTranslateY(500.0f);
2088 v1->SetTransform(transform); 2088 v1->SetTransform(transform);
2089 2089
2090 // |v2| now occupies (100, 200) to (200, 400) in |root|. 2090 // |v2| now occupies (100, 200) to (200, 400) in |root|.
2091 v1->Reset(); 2091 v1->Reset();
2092 v2->Reset(); 2092 v2->Reset();
2093 2093
2094 gfx::Point p1(110, 210); 2094 gfx::Point p1(110, 210);
2095 ui::MouseEvent pressed(ui::ET_MOUSE_PRESSED, p1, p1, 2095 ui::MouseEvent pressed(ui::ET_MOUSE_PRESSED, p1, p1,
(...skipping 23 matching lines...) Expand all
2119 ui::MouseEvent p2(ui::ET_MOUSE_PRESSED, point2, point2, 2119 ui::MouseEvent p2(ui::ET_MOUSE_PRESSED, point2, point2,
2120 ui::EF_LEFT_MOUSE_BUTTON); 2120 ui::EF_LEFT_MOUSE_BUTTON);
2121 root->OnMousePressed(p2); 2121 root->OnMousePressed(p2);
2122 EXPECT_EQ(0, v1->last_mouse_event_type_); 2122 EXPECT_EQ(0, v1->last_mouse_event_type_);
2123 EXPECT_EQ(ui::ET_MOUSE_PRESSED, v2->last_mouse_event_type_); 2123 EXPECT_EQ(ui::ET_MOUSE_PRESSED, v2->last_mouse_event_type_);
2124 EXPECT_EQ(10, v2->location_.x()); 2124 EXPECT_EQ(10, v2->location_.x());
2125 EXPECT_EQ(20, v2->location_.y()); 2125 EXPECT_EQ(20, v2->location_.y());
2126 2126
2127 root->OnMouseReleased(released); 2127 root->OnMouseReleased(released);
2128 2128
2129 v1->SetTransform(ui::Transform()); 2129 v1->SetTransform(gfx::Transform());
2130 v2->SetTransform(ui::Transform()); 2130 v2->SetTransform(gfx::Transform());
2131 2131
2132 TestView* v3 = new TestView(); 2132 TestView* v3 = new TestView();
2133 v3->SetBoundsRect(gfx::Rect(10, 10, 20, 30)); 2133 v3->SetBoundsRect(gfx::Rect(10, 10, 20, 30));
2134 v2->AddChildView(v3); 2134 v2->AddChildView(v3);
2135 2135
2136 // Rotate |v3| clockwise with respect to |v2|. 2136 // Rotate |v3| clockwise with respect to |v2|.
2137 transform = v1->GetTransform(); 2137 transform = v1->GetTransform();
2138 RotateClockwise(&transform); 2138 RotateClockwise(&transform);
2139 transform.SetTranslateX(30.0f); 2139 transform.SetTranslateX(30.0f);
2140 v3->SetTransform(transform); 2140 v3->SetTransform(transform);
(...skipping 13 matching lines...) Expand all
2154 ui::MouseEvent p3(ui::ET_MOUSE_PRESSED, point, point, 2154 ui::MouseEvent p3(ui::ET_MOUSE_PRESSED, point, point,
2155 ui::EF_LEFT_MOUSE_BUTTON); 2155 ui::EF_LEFT_MOUSE_BUTTON);
2156 root->OnMousePressed(p3); 2156 root->OnMousePressed(p3);
2157 2157
2158 EXPECT_EQ(ui::ET_MOUSE_PRESSED, v3->last_mouse_event_type_); 2158 EXPECT_EQ(ui::ET_MOUSE_PRESSED, v3->last_mouse_event_type_);
2159 EXPECT_EQ(10, v3->location_.x()); 2159 EXPECT_EQ(10, v3->location_.x());
2160 EXPECT_EQ(25, v3->location_.y()); 2160 EXPECT_EQ(25, v3->location_.y());
2161 2161
2162 root->OnMouseReleased(released); 2162 root->OnMouseReleased(released);
2163 2163
2164 v1->SetTransform(ui::Transform()); 2164 v1->SetTransform(gfx::Transform());
2165 v2->SetTransform(ui::Transform()); 2165 v2->SetTransform(gfx::Transform());
2166 v3->SetTransform(ui::Transform()); 2166 v3->SetTransform(gfx::Transform());
2167 2167
2168 v1->Reset(); 2168 v1->Reset();
2169 v2->Reset(); 2169 v2->Reset();
2170 v3->Reset(); 2170 v3->Reset();
2171 2171
2172 // Rotate |v3| clockwise with respect to |v2|, and scale it along both axis. 2172 // Rotate |v3| clockwise with respect to |v2|, and scale it along both axis.
2173 transform = v3->GetTransform(); 2173 transform = v3->GetTransform();
2174 RotateClockwise(&transform); 2174 RotateClockwise(&transform);
2175 transform.SetTranslateX(30.0f); 2175 transform.SetTranslateX(30.0f);
2176 // Rotation sets some scaling transformation. Using SetScale would overwrite 2176 // Rotation sets some scaling transformation. Using SetScale would overwrite
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
2216 viewport->AddChildView(contents); 2216 viewport->AddChildView(contents);
2217 viewport->SetBoundsRect(viewport_bounds); 2217 viewport->SetBoundsRect(viewport_bounds);
2218 contents->SetBoundsRect(gfx::Rect(0, 0, 100, 200)); 2218 contents->SetBoundsRect(gfx::Rect(0, 0, 100, 200));
2219 2219
2220 View* child = new View; 2220 View* child = new View;
2221 contents->AddChildView(child); 2221 contents->AddChildView(child);
2222 child->SetBoundsRect(gfx::Rect(10, 90, 50, 50)); 2222 child->SetBoundsRect(gfx::Rect(10, 90, 50, 50));
2223 EXPECT_EQ(gfx::Rect(0, 0, 50, 10), child->GetVisibleBounds()); 2223 EXPECT_EQ(gfx::Rect(0, 0, 50, 10), child->GetVisibleBounds());
2224 2224
2225 // Rotate |child| counter-clockwise 2225 // Rotate |child| counter-clockwise
2226 ui::Transform transform; 2226 gfx::Transform transform;
2227 RotateCounterclockwise(&transform); 2227 RotateCounterclockwise(&transform);
2228 transform.SetTranslateY(50.0f); 2228 transform.SetTranslateY(50.0f);
2229 child->SetTransform(transform); 2229 child->SetTransform(transform);
2230 EXPECT_EQ(gfx::Rect(40, 0, 10, 50), child->GetVisibleBounds()); 2230 EXPECT_EQ(gfx::Rect(40, 0, 10, 50), child->GetVisibleBounds());
2231 2231
2232 widget->CloseNow(); 2232 widget->CloseNow();
2233 } 2233 }
2234 2234
2235 //////////////////////////////////////////////////////////////////////////////// 2235 ////////////////////////////////////////////////////////////////////////////////
2236 // OnVisibleBoundsChanged() 2236 // OnVisibleBoundsChanged()
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
2332 TestView top_view; 2332 TestView top_view;
2333 TestView* child = new TestView; 2333 TestView* child = new TestView;
2334 TestView* child_child = new TestView; 2334 TestView* child_child = new TestView;
2335 2335
2336 top_view.AddChildView(child); 2336 top_view.AddChildView(child);
2337 child->AddChildView(child_child); 2337 child->AddChildView(child_child);
2338 2338
2339 top_view.SetBoundsRect(gfx::Rect(0, 0, 1000, 1000)); 2339 top_view.SetBoundsRect(gfx::Rect(0, 0, 1000, 1000));
2340 2340
2341 child->SetBoundsRect(gfx::Rect(7, 19, 500, 500)); 2341 child->SetBoundsRect(gfx::Rect(7, 19, 500, 500));
2342 ui::Transform transform; 2342 gfx::Transform transform;
2343 transform.SetScale(3.0f, 4.0f); 2343 transform.SetScale(3.0f, 4.0f);
2344 child->SetTransform(transform); 2344 child->SetTransform(transform);
2345 2345
2346 child_child->SetBoundsRect(gfx::Rect(17, 13, 100, 100)); 2346 child_child->SetBoundsRect(gfx::Rect(17, 13, 100, 100));
2347 transform = ui::Transform(); 2347 transform = gfx::Transform();
2348 transform.SetScale(5.0f, 7.0f); 2348 transform.SetScale(5.0f, 7.0f);
2349 child_child->SetTransform(transform); 2349 child_child->SetTransform(transform);
2350 2350
2351 // Sanity check to make sure basic transforms act as expected. 2351 // Sanity check to make sure basic transforms act as expected.
2352 { 2352 {
2353 ui::Transform transform; 2353 gfx::Transform transform;
2354 transform.ConcatTranslate(1, 1); 2354 transform.ConcatTranslate(1, 1);
2355 transform.ConcatScale(100, 55); 2355 transform.ConcatScale(100, 55);
2356 transform.ConcatTranslate(110, -110); 2356 transform.ConcatTranslate(110, -110);
2357 2357
2358 // convert to a 3x3 matrix. 2358 // convert to a 3x3 matrix.
2359 const SkMatrix& matrix = transform.matrix(); 2359 const SkMatrix& matrix = transform.matrix();
2360 2360
2361 EXPECT_EQ(210, matrix.getTranslateX()); 2361 EXPECT_EQ(210, matrix.getTranslateX());
2362 EXPECT_EQ(-55, matrix.getTranslateY()); 2362 EXPECT_EQ(-55, matrix.getTranslateY());
2363 EXPECT_EQ(100, matrix.getScaleX()); 2363 EXPECT_EQ(100, matrix.getScaleX());
2364 EXPECT_EQ(55, matrix.getScaleY()); 2364 EXPECT_EQ(55, matrix.getScaleY());
2365 EXPECT_EQ(0, matrix.getSkewX()); 2365 EXPECT_EQ(0, matrix.getSkewX());
2366 EXPECT_EQ(0, matrix.getSkewY()); 2366 EXPECT_EQ(0, matrix.getSkewY());
2367 } 2367 }
2368 2368
2369 { 2369 {
2370 ui::Transform transform; 2370 gfx::Transform transform;
2371 transform.SetTranslate(1, 1); 2371 transform.SetTranslate(1, 1);
2372 ui::Transform t2; 2372 gfx::Transform t2;
2373 t2.SetScale(100, 55); 2373 t2.SetScale(100, 55);
2374 ui::Transform t3; 2374 gfx::Transform t3;
2375 t3.SetTranslate(110, -110); 2375 t3.SetTranslate(110, -110);
2376 transform.ConcatTransform(t2); 2376 transform.ConcatTransform(t2);
2377 transform.ConcatTransform(t3); 2377 transform.ConcatTransform(t3);
2378 2378
2379 // convert to a 3x3 matrix 2379 // convert to a 3x3 matrix
2380 const SkMatrix& matrix = transform.matrix(); 2380 const SkMatrix& matrix = transform.matrix();
2381 2381
2382 EXPECT_EQ(210, matrix.getTranslateX()); 2382 EXPECT_EQ(210, matrix.getTranslateX());
2383 EXPECT_EQ(-55, matrix.getTranslateY()); 2383 EXPECT_EQ(-55, matrix.getTranslateY());
2384 EXPECT_EQ(100, matrix.getScaleX()); 2384 EXPECT_EQ(100, matrix.getScaleX());
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
2452 2452
2453 v1->SetBoundsRect(gfx::Rect(10, 10, 500, 500)); 2453 v1->SetBoundsRect(gfx::Rect(10, 10, 500, 500));
2454 v2->SetBoundsRect(gfx::Rect(20, 20, 100, 200)); 2454 v2->SetBoundsRect(gfx::Rect(20, 20, 100, 200));
2455 2455
2456 // |v2| now occupies (30, 30) to (130, 230) in |widget| 2456 // |v2| now occupies (30, 30) to (130, 230) in |widget|
2457 gfx::Rect rect(5, 5, 15, 40); 2457 gfx::Rect rect(5, 5, 15, 40);
2458 EXPECT_EQ(gfx::Rect(25, 25, 15, 40), v2->ConvertRectToParent(rect)); 2458 EXPECT_EQ(gfx::Rect(25, 25, 15, 40), v2->ConvertRectToParent(rect));
2459 EXPECT_EQ(gfx::Rect(35, 35, 15, 40), v2->ConvertRectToWidget(rect)); 2459 EXPECT_EQ(gfx::Rect(35, 35, 15, 40), v2->ConvertRectToWidget(rect));
2460 2460
2461 // Rotate |v2| 2461 // Rotate |v2|
2462 ui::Transform t2; 2462 gfx::Transform t2;
2463 RotateCounterclockwise(&t2); 2463 RotateCounterclockwise(&t2);
2464 t2.SetTranslateY(100.0f); 2464 t2.SetTranslateY(100.0f);
2465 v2->SetTransform(t2); 2465 v2->SetTransform(t2);
2466 2466
2467 // |v2| now occupies (30, 30) to (230, 130) in |widget| 2467 // |v2| now occupies (30, 30) to (230, 130) in |widget|
2468 EXPECT_EQ(gfx::Rect(25, 100, 40, 15), v2->ConvertRectToParent(rect)); 2468 EXPECT_EQ(gfx::Rect(25, 100, 40, 15), v2->ConvertRectToParent(rect));
2469 EXPECT_EQ(gfx::Rect(35, 110, 40, 15), v2->ConvertRectToWidget(rect)); 2469 EXPECT_EQ(gfx::Rect(35, 110, 40, 15), v2->ConvertRectToWidget(rect));
2470 2470
2471 // Scale down |v1| 2471 // Scale down |v1|
2472 ui::Transform t1; 2472 gfx::Transform t1;
2473 t1.SetScale(0.5, 0.5); 2473 t1.SetScale(0.5, 0.5);
2474 v1->SetTransform(t1); 2474 v1->SetTransform(t1);
2475 2475
2476 // The rectangle should remain the same for |v1|. 2476 // The rectangle should remain the same for |v1|.
2477 EXPECT_EQ(gfx::Rect(25, 100, 40, 15), v2->ConvertRectToParent(rect)); 2477 EXPECT_EQ(gfx::Rect(25, 100, 40, 15), v2->ConvertRectToParent(rect));
2478 2478
2479 // |v2| now occupies (20, 20) to (120, 70) in |widget| 2479 // |v2| now occupies (20, 20) to (120, 70) in |widget|
2480 // There are some rounding of floating values here. These values may change if 2480 // There are some rounding of floating values here. These values may change if
2481 // floating operations are improved/changed. 2481 // floating operations are improved/changed.
2482 EXPECT_EQ(gfx::Rect(22, 60, 20, 7), v2->ConvertRectToWidget(rect)); 2482 EXPECT_EQ(gfx::Rect(22, 60, 20, 7), v2->ConvertRectToWidget(rect));
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after
2969 EXPECT_TRUE(v1->layer() == NULL); 2969 EXPECT_TRUE(v1->layer() == NULL);
2970 EXPECT_TRUE(v2->layer() != NULL); 2970 EXPECT_TRUE(v2->layer() != NULL);
2971 EXPECT_EQ(root_layer, v2->layer()->parent()); 2971 EXPECT_EQ(root_layer, v2->layer()->parent());
2972 ASSERT_EQ(1u, root_layer->children().size()); 2972 ASSERT_EQ(1u, root_layer->children().size());
2973 EXPECT_EQ(root_layer->children()[0], v2->layer()); 2973 EXPECT_EQ(root_layer->children()[0], v2->layer());
2974 // The bounds of the layer should have changed to be relative to the root view 2974 // The bounds of the layer should have changed to be relative to the root view
2975 // now. 2975 // now.
2976 EXPECT_EQ(gfx::Rect(30, 50, 30, 40), v2->layer()->bounds()); 2976 EXPECT_EQ(gfx::Rect(30, 50, 30, 40), v2->layer()->bounds());
2977 2977
2978 // Make v1 have a layer again and verify v2s layer is wired up correctly. 2978 // Make v1 have a layer again and verify v2s layer is wired up correctly.
2979 ui::Transform transform; 2979 gfx::Transform transform;
2980 transform.SetScale(2.0f, 2.0f); 2980 transform.SetScale(2.0f, 2.0f);
2981 v1->SetTransform(transform); 2981 v1->SetTransform(transform);
2982 EXPECT_TRUE(v1->layer() != NULL); 2982 EXPECT_TRUE(v1->layer() != NULL);
2983 EXPECT_TRUE(v2->layer() != NULL); 2983 EXPECT_TRUE(v2->layer() != NULL);
2984 EXPECT_EQ(root_layer, v1->layer()->parent()); 2984 EXPECT_EQ(root_layer, v1->layer()->parent());
2985 EXPECT_EQ(v1->layer(), v2->layer()->parent()); 2985 EXPECT_EQ(v1->layer(), v2->layer()->parent());
2986 ASSERT_EQ(1u, root_layer->children().size()); 2986 ASSERT_EQ(1u, root_layer->children().size());
2987 EXPECT_EQ(root_layer->children()[0], v1->layer()); 2987 EXPECT_EQ(root_layer->children()[0], v1->layer());
2988 ASSERT_EQ(1u, v1->layer()->children().size()); 2988 ASSERT_EQ(1u, v1->layer()->children().size());
2989 EXPECT_EQ(v1->layer()->children()[0], v2->layer()); 2989 EXPECT_EQ(v1->layer()->children()[0], v2->layer());
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
3121 l2bounds.set_x(l2bounds.x() - 5); 3121 l2bounds.set_x(l2bounds.x() - 5);
3122 EXPECT_EQ(l2bounds, v2->layer()->bounds()); 3122 EXPECT_EQ(l2bounds, v2->layer()->bounds());
3123 3123
3124 // Reset locale. 3124 // Reset locale.
3125 base::i18n::SetICUDefaultLocale(locale); 3125 base::i18n::SetICUDefaultLocale(locale);
3126 } 3126 }
3127 3127
3128 // Makes sure a transform persists after toggling the visibility. 3128 // Makes sure a transform persists after toggling the visibility.
3129 TEST_F(ViewLayerTest, ToggleVisibilityWithTransform) { 3129 TEST_F(ViewLayerTest, ToggleVisibilityWithTransform) {
3130 View* view = new View; 3130 View* view = new View;
3131 ui::Transform transform; 3131 gfx::Transform transform;
3132 transform.SetScale(2.0f, 2.0f); 3132 transform.SetScale(2.0f, 2.0f);
3133 view->SetTransform(transform); 3133 view->SetTransform(transform);
3134 widget()->SetContentsView(view); 3134 widget()->SetContentsView(view);
3135 EXPECT_EQ(2.0f, view->GetTransform().matrix().get(0, 0)); 3135 EXPECT_EQ(2.0f, view->GetTransform().matrix().get(0, 0));
3136 3136
3137 view->SetVisible(false); 3137 view->SetVisible(false);
3138 EXPECT_EQ(2.0f, view->GetTransform().matrix().get(0, 0)); 3138 EXPECT_EQ(2.0f, view->GetTransform().matrix().get(0, 0));
3139 3139
3140 view->SetVisible(true); 3140 view->SetVisible(true);
3141 EXPECT_EQ(2.0f, view->GetTransform().matrix().get(0, 0)); 3141 EXPECT_EQ(2.0f, view->GetTransform().matrix().get(0, 0));
3142 } 3142 }
3143 3143
3144 // Verifies a transform persists after removing/adding a view with a transform. 3144 // Verifies a transform persists after removing/adding a view with a transform.
3145 TEST_F(ViewLayerTest, ResetTransformOnLayerAfterAdd) { 3145 TEST_F(ViewLayerTest, ResetTransformOnLayerAfterAdd) {
3146 View* view = new View; 3146 View* view = new View;
3147 ui::Transform transform; 3147 gfx::Transform transform;
3148 transform.SetScale(2.0f, 2.0f); 3148 transform.SetScale(2.0f, 2.0f);
3149 view->SetTransform(transform); 3149 view->SetTransform(transform);
3150 widget()->SetContentsView(view); 3150 widget()->SetContentsView(view);
3151 EXPECT_EQ(2.0f, view->GetTransform().matrix().get(0, 0)); 3151 EXPECT_EQ(2.0f, view->GetTransform().matrix().get(0, 0));
3152 ASSERT_TRUE(view->layer() != NULL); 3152 ASSERT_TRUE(view->layer() != NULL);
3153 EXPECT_EQ(2.0f, view->layer()->transform().matrix().get(0, 0)); 3153 EXPECT_EQ(2.0f, view->layer()->transform().matrix().get(0, 0));
3154 3154
3155 View* parent = view->parent(); 3155 View* parent = view->parent();
3156 parent->RemoveChildView(view); 3156 parent->RemoveChildView(view);
3157 parent->AddChildView(view); 3157 parent->AddChildView(view);
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
3383 // Set to non default value. 3383 // Set to non default value.
3384 v->layer()->set_scale_content(false); 3384 v->layer()->set_scale_content(false);
3385 scoped_ptr<ui::Layer> old_layer(v->RecreateLayer()); 3385 scoped_ptr<ui::Layer> old_layer(v->RecreateLayer());
3386 ui::Layer* new_layer = v->layer(); 3386 ui::Layer* new_layer = v->layer();
3387 EXPECT_FALSE(new_layer->scale_content()); 3387 EXPECT_FALSE(new_layer->scale_content());
3388 } 3388 }
3389 3389
3390 #endif // USE_AURA 3390 #endif // USE_AURA
3391 3391
3392 } // namespace views 3392 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/view.cc ('k') | ui/views/widget/widget.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698