OLD | NEW |
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/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 2937 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2948 | 2948 |
2949 // Move a view again. | 2949 // Move a view again. |
2950 v2->SetBounds(v2->x() + 5, v2->y(), v2->width(), v2->height()); | 2950 v2->SetBounds(v2->x() + 5, v2->y(), v2->width(), v2->height()); |
2951 l2bounds.set_x(l2bounds.x() - 5); | 2951 l2bounds.set_x(l2bounds.x() - 5); |
2952 EXPECT_EQ(l2bounds, v2->layer()->bounds()); | 2952 EXPECT_EQ(l2bounds, v2->layer()->bounds()); |
2953 | 2953 |
2954 // Reset locale. | 2954 // Reset locale. |
2955 base::i18n::SetICUDefaultLocale(locale); | 2955 base::i18n::SetICUDefaultLocale(locale); |
2956 } | 2956 } |
2957 | 2957 |
| 2958 // Make sure that resizing a parent in RTL correctly repositions its children. |
| 2959 TEST_F(ViewLayerTest, ResizeParentInRTL) { |
| 2960 std::string locale = l10n_util::GetApplicationLocale(std::string()); |
| 2961 base::i18n::SetICUDefaultLocale("he"); |
| 2962 |
| 2963 View* view = new View; |
| 2964 widget()->SetContentsView(view); |
| 2965 |
| 2966 int content_width = view->width(); |
| 2967 |
| 2968 // Create a paints-to-layer view |v1|. |
| 2969 View* v1 = new View; |
| 2970 v1->SetPaintToLayer(true); |
| 2971 v1->SetBounds(10, 10, 20, 10); |
| 2972 view->AddChildView(v1); |
| 2973 EXPECT_EQ(gfx::Rect(content_width - 30, 10, 20, 10), |
| 2974 v1->layer()->bounds()); |
| 2975 |
| 2976 // Attach a paints-to-layer child view to |v1|. |
| 2977 View* v2 = new View; |
| 2978 v2->SetPaintToLayer(true); |
| 2979 v2->SetBounds(3, 5, 6, 4); |
| 2980 EXPECT_EQ(gfx::Rect(3, 5, 6, 4), |
| 2981 v2->layer()->bounds()); |
| 2982 v1->AddChildView(v2); |
| 2983 // Check that |v2| now has RTL-appropriate bounds. |
| 2984 EXPECT_EQ(gfx::Rect(11, 5, 6, 4), |
| 2985 v2->layer()->bounds()); |
| 2986 |
| 2987 // Attach a non-layer child view to |v1|, and give it a paints-to-layer child. |
| 2988 View* v3 = new View; |
| 2989 v3->SetBounds(1, 1, 18, 8); |
| 2990 View* v4 = new View; |
| 2991 v4->SetPaintToLayer(true); |
| 2992 v4->SetBounds(2, 4, 6, 4); |
| 2993 EXPECT_EQ(gfx::Rect(2, 4, 6, 4), |
| 2994 v4->layer()->bounds()); |
| 2995 v3->AddChildView(v4); |
| 2996 EXPECT_EQ(gfx::Rect(10, 4, 6, 4), |
| 2997 v4->layer()->bounds()); |
| 2998 v1->AddChildView(v3); |
| 2999 // Check that |v4| now has RTL-appropriate bounds. |
| 3000 EXPECT_EQ(gfx::Rect(11, 5, 6, 4), |
| 3001 v4->layer()->bounds()); |
| 3002 |
| 3003 // Resize |v1|. Make sure that |v2| and |v4|'s layers have been moved |
| 3004 // correctly to RTL-appropriate bounds. |
| 3005 v1->SetSize(gfx::Size(30, 10)); |
| 3006 EXPECT_EQ(gfx::Rect(21, 5, 6, 4), |
| 3007 v2->layer()->bounds()); |
| 3008 EXPECT_EQ(gfx::Rect(21, 5, 6, 4), |
| 3009 v4->layer()->bounds()); |
| 3010 |
| 3011 // Move and resize |v3|. Make sure that |v4|'s layer has been moved correctly |
| 3012 // to RTL-appropriate bounds. |
| 3013 v3->SetBounds(2, 1, 12, 8); |
| 3014 EXPECT_EQ(gfx::Rect(20, 5, 6, 4), |
| 3015 v4->layer()->bounds()); |
| 3016 |
| 3017 // Reset locale. |
| 3018 base::i18n::SetICUDefaultLocale(locale); |
| 3019 } |
| 3020 |
2958 // Makes sure a transform persists after toggling the visibility. | 3021 // Makes sure a transform persists after toggling the visibility. |
2959 TEST_F(ViewLayerTest, ToggleVisibilityWithTransform) { | 3022 TEST_F(ViewLayerTest, ToggleVisibilityWithTransform) { |
2960 View* view = new View; | 3023 View* view = new View; |
2961 gfx::Transform transform; | 3024 gfx::Transform transform; |
2962 transform.Scale(2.0, 2.0); | 3025 transform.Scale(2.0, 2.0); |
2963 view->SetTransform(transform); | 3026 view->SetTransform(transform); |
2964 widget()->SetContentsView(view); | 3027 widget()->SetContentsView(view); |
2965 EXPECT_EQ(2.0f, view->GetTransform().matrix().get(0, 0)); | 3028 EXPECT_EQ(2.0f, view->GetTransform().matrix().get(0, 0)); |
2966 | 3029 |
2967 view->SetVisible(false); | 3030 view->SetVisible(false); |
(...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3688 // notification. | 3751 // notification. |
3689 TestView* test_view_child_2 = new TestView(); | 3752 TestView* test_view_child_2 = new TestView(); |
3690 test_view->AddChildView(test_view_child_2); | 3753 test_view->AddChildView(test_view_child_2); |
3691 EXPECT_TRUE(test_view_child_2->native_theme_); | 3754 EXPECT_TRUE(test_view_child_2->native_theme_); |
3692 EXPECT_EQ(widget->GetNativeTheme(), test_view_child_2->native_theme_); | 3755 EXPECT_EQ(widget->GetNativeTheme(), test_view_child_2->native_theme_); |
3693 | 3756 |
3694 widget->CloseNow(); | 3757 widget->CloseNow(); |
3695 } | 3758 } |
3696 | 3759 |
3697 } // namespace views | 3760 } // namespace views |
OLD | NEW |