| OLD | NEW |
| 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 "base/strings/utf_string_conversions.h" | 5 #include "base/strings/utf_string_conversions.h" |
| 6 #include "ui/base/hit_test.h" | 6 #include "ui/base/hit_test.h" |
| 7 #include "ui/views/bubble/bubble_border.h" | 7 #include "ui/views/bubble/bubble_border.h" |
| 8 #include "ui/views/bubble/bubble_frame_view.h" | 8 #include "ui/views/bubble/bubble_frame_view.h" |
| 9 #include "ui/views/controls/button/button_dropdown.h" | 9 #include "ui/views/controls/button/button_dropdown.h" |
| 10 #include "ui/views/controls/button/checkbox.h" | 10 #include "ui/views/controls/button/checkbox.h" |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 dialog()->CheckAndResetStates(true, false, NULL); | 197 dialog()->CheckAndResetStates(true, false, NULL); |
| 198 } | 198 } |
| 199 | 199 |
| 200 TEST_F(DialogTest, RemoveDefaultButton) { | 200 TEST_F(DialogTest, RemoveDefaultButton) { |
| 201 // Removing buttons from the dialog here should not cause a crash on close. | 201 // Removing buttons from the dialog here should not cause a crash on close. |
| 202 delete dialog()->GetDialogClientView()->ok_button(); | 202 delete dialog()->GetDialogClientView()->ok_button(); |
| 203 delete dialog()->GetDialogClientView()->cancel_button(); | 203 delete dialog()->GetDialogClientView()->cancel_button(); |
| 204 } | 204 } |
| 205 | 205 |
| 206 TEST_F(DialogTest, HitTest) { | 206 TEST_F(DialogTest, HitTest) { |
| 207 if (!DialogDelegate::UseNewStyle()) | |
| 208 return; | |
| 209 | |
| 210 // Ensure that the new style's BubbleFrameView hit-tests as expected. | 207 // Ensure that the new style's BubbleFrameView hit-tests as expected. |
| 211 const NonClientView* view = dialog()->GetWidget()->non_client_view(); | 208 const NonClientView* view = dialog()->GetWidget()->non_client_view(); |
| 212 BubbleFrameView* frame = static_cast<BubbleFrameView*>(view->frame_view()); | 209 BubbleFrameView* frame = static_cast<BubbleFrameView*>(view->frame_view()); |
| 213 const int border = frame->bubble_border()->GetBorderThickness(); | 210 const int border = frame->bubble_border()->GetBorderThickness(); |
| 214 | 211 |
| 215 struct { | 212 struct { |
| 216 const int point; | 213 const int point; |
| 217 const int hit; | 214 const int hit; |
| 218 } cases[] = { | 215 } cases[] = { |
| 219 { border, HTSYSMENU }, | 216 { border, HTSYSMENU }, |
| 220 { border + 10, HTSYSMENU }, | 217 { border + 10, HTSYSMENU }, |
| 221 { border + 20, HTCAPTION }, | 218 { border + 20, HTCAPTION }, |
| 222 { border + 40, HTCLIENT }, | 219 { border + 40, HTCLIENT }, |
| 223 { border + 50, HTCLIENT }, | 220 { border + 50, HTCLIENT }, |
| 224 { 1000, HTNOWHERE }, | 221 { 1000, HTNOWHERE }, |
| 225 }; | 222 }; |
| 226 | 223 |
| 227 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) { | 224 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) { |
| 228 gfx::Point point(cases[i].point, cases[i].point); | 225 gfx::Point point(cases[i].point, cases[i].point); |
| 229 EXPECT_EQ(cases[i].hit, frame->NonClientHitTest(point)) | 226 EXPECT_EQ(cases[i].hit, frame->NonClientHitTest(point)) |
| 230 << " with border: " << border << ", at point " << cases[i].point; | 227 << " with border: " << border << ", at point " << cases[i].point; |
| 231 } | 228 } |
| 232 } | 229 } |
| 233 | 230 |
| 234 TEST_F(DialogTest, InitialBoundsAccommodateTitle) { | 231 TEST_F(DialogTest, InitialBoundsAccommodateTitle) { |
| 235 if (!DialogDelegate::UseNewStyle()) | |
| 236 return; | |
| 237 | |
| 238 TestDialog* titled_dialog(new TestDialog()); | 232 TestDialog* titled_dialog(new TestDialog()); |
| 239 titled_dialog->set_title(ASCIIToUTF16("Title")); | 233 titled_dialog->set_title(ASCIIToUTF16("Title")); |
| 240 DialogDelegate::CreateDialogWidget(titled_dialog, GetContext(), NULL); | 234 DialogDelegate::CreateDialogWidget(titled_dialog, GetContext(), NULL); |
| 241 | 235 |
| 242 // Titled dialogs have taller initial frame bounds than untitled dialogs. | 236 // Titled dialogs have taller initial frame bounds than untitled dialogs. |
| 243 EXPECT_GT(titled_dialog->GetWidget()->GetWindowBoundsInScreen().height(), | 237 EXPECT_GT(titled_dialog->GetWidget()->GetWindowBoundsInScreen().height(), |
| 244 dialog()->GetWidget()->GetWindowBoundsInScreen().height()); | 238 dialog()->GetWidget()->GetWindowBoundsInScreen().height()); |
| 245 | 239 |
| 246 // Giving the default test dialog a title will make the bounds the same. | 240 // Giving the default test dialog a title will make the bounds the same. |
| 247 dialog()->set_title(ASCIIToUTF16("Title")); | 241 dialog()->set_title(ASCIIToUTF16("Title")); |
| 248 dialog()->GetWidget()->UpdateWindowTitle(); | 242 dialog()->GetWidget()->UpdateWindowTitle(); |
| 249 View* frame = dialog()->GetWidget()->non_client_view()->frame_view(); | 243 View* frame = dialog()->GetWidget()->non_client_view()->frame_view(); |
| 250 EXPECT_EQ(titled_dialog->GetWidget()->GetWindowBoundsInScreen().height(), | 244 EXPECT_EQ(titled_dialog->GetWidget()->GetWindowBoundsInScreen().height(), |
| 251 frame->GetPreferredSize().height()); | 245 frame->GetPreferredSize().height()); |
| 252 } | 246 } |
| 253 | 247 |
| 254 } // namespace views | 248 } // namespace views |
| OLD | NEW |