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

Side by Side Diff: ash/frame/caption_buttons/frame_caption_button_container_view_unittest.cc

Issue 271913002: Animate window control changes in TouchView (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 6 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "ash/frame/caption_buttons/frame_caption_button_container_view.h" 5 #include "ash/frame/caption_buttons/frame_caption_button_container_view.h"
6 6
7 #include "ash/frame/caption_buttons/frame_caption_button.h" 7 #include "ash/frame/caption_buttons/frame_caption_button.h"
8 #include "ash/test/ash_test_base.h" 8 #include "ash/test/ash_test_base.h"
9 #include "grit/ash_resources.h" 9 #include "grit/ash_resources.h"
10 #include "ui/gfx/geometry/rect.h"
10 #include "ui/views/widget/widget.h" 11 #include "ui/views/widget/widget.h"
11 #include "ui/views/widget/widget_delegate.h" 12 #include "ui/views/widget/widget_delegate.h"
12 13
13 namespace ash { 14 namespace ash {
14 15
15 namespace { 16 namespace {
16 17
17 class TestWidgetDelegate : public views::WidgetDelegateView { 18 class TestWidgetDelegate : public views::WidgetDelegateView {
18 public: 19 public:
19 TestWidgetDelegate(bool can_maximize) : can_maximize_(can_maximize) { 20 TestWidgetDelegate(bool can_maximize) : can_maximize_(can_maximize) {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 102
102 // Test how the allowed actions affect which caption buttons are visible. 103 // Test how the allowed actions affect which caption buttons are visible.
103 TEST_F(FrameCaptionButtonContainerViewTest, ButtonVisibility) { 104 TEST_F(FrameCaptionButtonContainerViewTest, ButtonVisibility) {
104 // All the buttons should be visible when minimizing and maximizing are 105 // All the buttons should be visible when minimizing and maximizing are
105 // allowed. 106 // allowed.
106 scoped_ptr<views::Widget> widget_can_maximize( 107 scoped_ptr<views::Widget> widget_can_maximize(
107 CreateTestWidget(MAXIMIZE_ALLOWED)); 108 CreateTestWidget(MAXIMIZE_ALLOWED));
108 FrameCaptionButtonContainerView container1(widget_can_maximize.get(), 109 FrameCaptionButtonContainerView container1(widget_can_maximize.get(),
109 FrameCaptionButtonContainerView::MINIMIZE_ALLOWED); 110 FrameCaptionButtonContainerView::MINIMIZE_ALLOWED);
110 SetMockImages(&container1); 111 SetMockImages(&container1);
112 container1.SetBoundsRect(gfx::Rect(container1.GetPreferredSize()));
111 container1.Layout(); 113 container1.Layout();
112 FrameCaptionButtonContainerView::TestApi t1(&container1); 114 FrameCaptionButtonContainerView::TestApi t1(&container1);
113 EXPECT_TRUE(t1.minimize_button()->visible()); 115 EXPECT_TRUE(t1.minimize_button()->visible());
114 EXPECT_TRUE(t1.size_button()->visible()); 116 EXPECT_TRUE(t1.size_button()->visible());
115 EXPECT_TRUE(t1.close_button()->visible()); 117 EXPECT_TRUE(t1.close_button()->visible());
116 EXPECT_TRUE(CheckButtonsAtEdges( 118 EXPECT_TRUE(CheckButtonsAtEdges(
117 &container1, *t1.minimize_button(), *t1.close_button())); 119 &container1, *t1.minimize_button(), *t1.close_button()));
118 120
119 // The minimize button should be visible when minimizing is allowed but 121 // The minimize button should be visible when minimizing is allowed but
120 // maximizing is disallowed. 122 // maximizing is disallowed.
121 scoped_ptr<views::Widget> widget_cannot_maximize( 123 scoped_ptr<views::Widget> widget_cannot_maximize(
122 CreateTestWidget(MAXIMIZE_DISALLOWED)); 124 CreateTestWidget(MAXIMIZE_DISALLOWED));
123 FrameCaptionButtonContainerView container2(widget_cannot_maximize.get(), 125 FrameCaptionButtonContainerView container2(widget_cannot_maximize.get(),
124 FrameCaptionButtonContainerView::MINIMIZE_ALLOWED); 126 FrameCaptionButtonContainerView::MINIMIZE_ALLOWED);
125 SetMockImages(&container2); 127 SetMockImages(&container2);
128 container2.SetBoundsRect(gfx::Rect(container2.GetPreferredSize()));
126 container2.Layout(); 129 container2.Layout();
127 FrameCaptionButtonContainerView::TestApi t2(&container2); 130 FrameCaptionButtonContainerView::TestApi t2(&container2);
128 EXPECT_TRUE(t2.minimize_button()->visible()); 131 EXPECT_TRUE(t2.minimize_button()->visible());
129 EXPECT_FALSE(t2.size_button()->visible()); 132 EXPECT_FALSE(t2.size_button()->visible());
130 EXPECT_TRUE(t2.close_button()->visible()); 133 EXPECT_TRUE(t2.close_button()->visible());
131 EXPECT_TRUE(CheckButtonsAtEdges( 134 EXPECT_TRUE(CheckButtonsAtEdges(
132 &container2, *t2.minimize_button(), *t2.close_button())); 135 &container2, *t2.minimize_button(), *t2.close_button()));
133 136
134 // Neither the minimize button nor the size button should be visible when 137 // Neither the minimize button nor the size button should be visible when
135 // neither minimizing nor maximizing are allowed. 138 // neither minimizing nor maximizing are allowed.
136 FrameCaptionButtonContainerView container3(widget_cannot_maximize.get(), 139 FrameCaptionButtonContainerView container3(widget_cannot_maximize.get(),
137 FrameCaptionButtonContainerView::MINIMIZE_DISALLOWED); 140 FrameCaptionButtonContainerView::MINIMIZE_DISALLOWED);
138 SetMockImages(&container3); 141 SetMockImages(&container3);
142 container3.SetBoundsRect(gfx::Rect(container3.GetPreferredSize()));
139 container3.Layout(); 143 container3.Layout();
140 FrameCaptionButtonContainerView::TestApi t3(&container3); 144 FrameCaptionButtonContainerView::TestApi t3(&container3);
141 EXPECT_FALSE(t3.minimize_button()->visible()); 145 EXPECT_FALSE(t3.minimize_button()->visible());
142 EXPECT_FALSE(t3.size_button()->visible()); 146 EXPECT_FALSE(t3.size_button()->visible());
143 EXPECT_TRUE(t3.close_button()->visible()); 147 EXPECT_TRUE(t3.close_button()->visible());
144 EXPECT_TRUE(CheckButtonsAtEdges( 148 EXPECT_TRUE(CheckButtonsAtEdges(
145 &container3, *t3.close_button(), *t3.close_button())); 149 &container3, *t3.close_button(), *t3.close_button()));
146 } 150 }
147 151
152 // Tests that the layout animations triggered by button visibilty result in the
153 // correct placement of the buttons.
154 TEST_F(FrameCaptionButtonContainerViewTest,
155 TestUpdateSizeButtonVisibilityAnimation) {
156 scoped_ptr<views::Widget> widget_can_maximize(
157 CreateTestWidget(MAXIMIZE_ALLOWED));
158 FrameCaptionButtonContainerView container(widget_can_maximize.get(),
159 FrameCaptionButtonContainerView::MINIMIZE_ALLOWED);
160 SetMockImages(&container);
161 container.SetBoundsRect(gfx::Rect(container.GetPreferredSize()));
162 container.Layout();
163
164 FrameCaptionButtonContainerView::TestApi test(&container);
165 gfx::Rect initial_minimize_button_bounds = test.minimize_button()->bounds();
166 gfx::Rect initial_size_button_bounds = test.size_button()->bounds();
167 gfx::Rect initial_close_button_bounds = test.close_button()->bounds();
168 gfx::Rect initial_container_bounds = container.bounds();
169
170 ASSERT_EQ(initial_size_button_bounds.x(),
171 initial_minimize_button_bounds.right());
172 ASSERT_EQ(initial_close_button_bounds.x(),
173 initial_size_button_bounds.right());
174
175 // Hidden size button should result in minimize button animating to the
176 // right. The size button should not be visible, but should not have moved.
177 container.UpdateSizeButtonVisibility(/*force_hidden*/ true);
178 container.Layout();
179
180 EXPECT_TRUE(test.minimize_button()->visible());
181 EXPECT_FALSE(test.size_button()->visible());
182 EXPECT_TRUE(test.close_button()->visible());
183 gfx::Rect minimize_button_bounds = test.minimize_button()->bounds();
184 gfx::Rect close_button_bounds = test.close_button()->bounds();
185 EXPECT_EQ(close_button_bounds.x(), minimize_button_bounds.right());
186 EXPECT_EQ(initial_size_button_bounds, test.size_button()->bounds());
187 EXPECT_EQ(initial_close_button_bounds, close_button_bounds);
188 EXPECT_LT(container.GetPreferredSize().width(),
189 initial_container_bounds.width());
190
191 // Revealing the size button should cause the minimze button to return to its
192 // original position.
193 container.UpdateSizeButtonVisibility(/*force_hidden*/ false);
194 container.Layout();
195 EXPECT_TRUE(test.minimize_button()->visible());
196 EXPECT_TRUE(test.size_button()->visible());
197 EXPECT_TRUE(test.close_button()->visible());
198 EXPECT_EQ(initial_minimize_button_bounds, test.minimize_button()->bounds());
199 EXPECT_EQ(initial_size_button_bounds, test.size_button()->bounds());
200 EXPECT_EQ(initial_close_button_bounds, test.close_button()->bounds());
201 EXPECT_EQ(container.GetPreferredSize().width(),
202 initial_container_bounds.width());
203 }
204
148 } // namespace ash 205 } // namespace ash
OLDNEW
« no previous file with comments | « ash/frame/caption_buttons/frame_caption_button_container_view.cc ('k') | ash/frame/custom_frame_view_ash.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698