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

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

Issue 309973002: Revert of 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"
11 #include "ui/views/widget/widget.h" 10 #include "ui/views/widget/widget.h"
12 #include "ui/views/widget/widget_delegate.h" 11 #include "ui/views/widget/widget_delegate.h"
13 12
14 namespace ash { 13 namespace ash {
15 14
16 namespace { 15 namespace {
17 16
18 class TestWidgetDelegate : public views::WidgetDelegateView { 17 class TestWidgetDelegate : public views::WidgetDelegateView {
19 public: 18 public:
20 TestWidgetDelegate(bool can_maximize) : can_maximize_(can_maximize) { 19 TestWidgetDelegate(bool can_maximize) : can_maximize_(can_maximize) {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 101
103 // Test how the allowed actions affect which caption buttons are visible. 102 // Test how the allowed actions affect which caption buttons are visible.
104 TEST_F(FrameCaptionButtonContainerViewTest, ButtonVisibility) { 103 TEST_F(FrameCaptionButtonContainerViewTest, ButtonVisibility) {
105 // All the buttons should be visible when minimizing and maximizing are 104 // All the buttons should be visible when minimizing and maximizing are
106 // allowed. 105 // allowed.
107 scoped_ptr<views::Widget> widget_can_maximize( 106 scoped_ptr<views::Widget> widget_can_maximize(
108 CreateTestWidget(MAXIMIZE_ALLOWED)); 107 CreateTestWidget(MAXIMIZE_ALLOWED));
109 FrameCaptionButtonContainerView container1(widget_can_maximize.get(), 108 FrameCaptionButtonContainerView container1(widget_can_maximize.get(),
110 FrameCaptionButtonContainerView::MINIMIZE_ALLOWED); 109 FrameCaptionButtonContainerView::MINIMIZE_ALLOWED);
111 SetMockImages(&container1); 110 SetMockImages(&container1);
112 container1.SetBoundsRect(gfx::Rect(container1.GetPreferredSize()));
113 container1.Layout(); 111 container1.Layout();
114 FrameCaptionButtonContainerView::TestApi t1(&container1); 112 FrameCaptionButtonContainerView::TestApi t1(&container1);
115 EXPECT_TRUE(t1.minimize_button()->visible()); 113 EXPECT_TRUE(t1.minimize_button()->visible());
116 EXPECT_TRUE(t1.size_button()->visible()); 114 EXPECT_TRUE(t1.size_button()->visible());
117 EXPECT_TRUE(t1.close_button()->visible()); 115 EXPECT_TRUE(t1.close_button()->visible());
118 EXPECT_TRUE(CheckButtonsAtEdges( 116 EXPECT_TRUE(CheckButtonsAtEdges(
119 &container1, *t1.minimize_button(), *t1.close_button())); 117 &container1, *t1.minimize_button(), *t1.close_button()));
120 118
121 // The minimize button should be visible when minimizing is allowed but 119 // The minimize button should be visible when minimizing is allowed but
122 // maximizing is disallowed. 120 // maximizing is disallowed.
123 scoped_ptr<views::Widget> widget_cannot_maximize( 121 scoped_ptr<views::Widget> widget_cannot_maximize(
124 CreateTestWidget(MAXIMIZE_DISALLOWED)); 122 CreateTestWidget(MAXIMIZE_DISALLOWED));
125 FrameCaptionButtonContainerView container2(widget_cannot_maximize.get(), 123 FrameCaptionButtonContainerView container2(widget_cannot_maximize.get(),
126 FrameCaptionButtonContainerView::MINIMIZE_ALLOWED); 124 FrameCaptionButtonContainerView::MINIMIZE_ALLOWED);
127 SetMockImages(&container2); 125 SetMockImages(&container2);
128 container2.SetBoundsRect(gfx::Rect(container2.GetPreferredSize()));
129 container2.Layout(); 126 container2.Layout();
130 FrameCaptionButtonContainerView::TestApi t2(&container2); 127 FrameCaptionButtonContainerView::TestApi t2(&container2);
131 EXPECT_TRUE(t2.minimize_button()->visible()); 128 EXPECT_TRUE(t2.minimize_button()->visible());
132 EXPECT_FALSE(t2.size_button()->visible()); 129 EXPECT_FALSE(t2.size_button()->visible());
133 EXPECT_TRUE(t2.close_button()->visible()); 130 EXPECT_TRUE(t2.close_button()->visible());
134 EXPECT_TRUE(CheckButtonsAtEdges( 131 EXPECT_TRUE(CheckButtonsAtEdges(
135 &container2, *t2.minimize_button(), *t2.close_button())); 132 &container2, *t2.minimize_button(), *t2.close_button()));
136 133
137 // Neither the minimize button nor the size button should be visible when 134 // Neither the minimize button nor the size button should be visible when
138 // neither minimizing nor maximizing are allowed. 135 // neither minimizing nor maximizing are allowed.
139 FrameCaptionButtonContainerView container3(widget_cannot_maximize.get(), 136 FrameCaptionButtonContainerView container3(widget_cannot_maximize.get(),
140 FrameCaptionButtonContainerView::MINIMIZE_DISALLOWED); 137 FrameCaptionButtonContainerView::MINIMIZE_DISALLOWED);
141 SetMockImages(&container3); 138 SetMockImages(&container3);
142 container3.SetBoundsRect(gfx::Rect(container3.GetPreferredSize()));
143 container3.Layout(); 139 container3.Layout();
144 FrameCaptionButtonContainerView::TestApi t3(&container3); 140 FrameCaptionButtonContainerView::TestApi t3(&container3);
145 EXPECT_FALSE(t3.minimize_button()->visible()); 141 EXPECT_FALSE(t3.minimize_button()->visible());
146 EXPECT_FALSE(t3.size_button()->visible()); 142 EXPECT_FALSE(t3.size_button()->visible());
147 EXPECT_TRUE(t3.close_button()->visible()); 143 EXPECT_TRUE(t3.close_button()->visible());
148 EXPECT_TRUE(CheckButtonsAtEdges( 144 EXPECT_TRUE(CheckButtonsAtEdges(
149 &container3, *t3.close_button(), *t3.close_button())); 145 &container3, *t3.close_button(), *t3.close_button()));
150 } 146 }
151 147
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
205 } // namespace ash 148 } // 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