Chromium Code Reviews| 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 "base/macros.h" | 5 #include "base/macros.h" |
| 6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
| 7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 #include "ui/gfx/geometry/insets.h" | 8 #include "ui/gfx/geometry/insets.h" |
| 9 #include "ui/gfx/geometry/rect.h" | 9 #include "ui/gfx/geometry/rect.h" |
| 10 #include "ui/gfx/geometry/size.h" | 10 #include "ui/gfx/geometry/size.h" |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 23 | 23 |
| 24 const BubbleBorder::Arrow kArrow = BubbleBorder::TOP_LEFT; | 24 const BubbleBorder::Arrow kArrow = BubbleBorder::TOP_LEFT; |
| 25 const SkColor kColor = SK_ColorRED; | 25 const SkColor kColor = SK_ColorRED; |
| 26 const int kMargin = 6; | 26 const int kMargin = 6; |
| 27 const int kMinimumClientWidth = 100; | 27 const int kMinimumClientWidth = 100; |
| 28 const int kMinimumClientHeight = 200; | 28 const int kMinimumClientHeight = 200; |
| 29 const int kMaximumClientWidth = 300; | 29 const int kMaximumClientWidth = 300; |
| 30 const int kMaximumClientHeight = 300; | 30 const int kMaximumClientHeight = 300; |
| 31 const int kPreferredClientWidth = 150; | 31 const int kPreferredClientWidth = 150; |
| 32 const int kPreferredClientHeight = 250; | 32 const int kPreferredClientHeight = 250; |
| 33 const int kExpectedBorderWidth = 22; | 33 |
| 34 const int kExpectedBorderHeight = 29; | 34 // The following do not take bubble border into consideration. |
|
msw
2016/03/14 17:16:25
Maybe describe what border this *does* account for
karandeepb
2016/03/14 23:35:39
Have clarified the comment. Yeah this is the size
msw
2016/03/15 00:00:49
NonClient seems ok to me, or maybe kExpectedAdditi
| |
| 35 const int kExpectedBorderWidth = 12; | |
| 36 const int kExpectedBorderHeight = 12; | |
| 35 | 37 |
| 36 class TestBubbleFrameViewWidgetDelegate : public WidgetDelegate { | 38 class TestBubbleFrameViewWidgetDelegate : public WidgetDelegate { |
| 37 public: | 39 public: |
| 38 TestBubbleFrameViewWidgetDelegate(Widget* widget) : widget_(widget) {} | 40 TestBubbleFrameViewWidgetDelegate(Widget* widget) : widget_(widget) {} |
| 39 | 41 |
| 40 ~TestBubbleFrameViewWidgetDelegate() override {} | 42 ~TestBubbleFrameViewWidgetDelegate() override {} |
| 41 | 43 |
| 42 // WidgetDelegate overrides: | 44 // WidgetDelegate overrides: |
| 43 Widget* GetWidget() override { return widget_; } | 45 Widget* GetWidget() override { return widget_; } |
| 44 const Widget* GetWidget() const override { return widget_; } | 46 const Widget* GetWidget() const override { return widget_; } |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 411 gfx::Size(500, 500), // |client_size| | 413 gfx::Size(500, 500), // |client_size| |
| 412 true); // |adjust_if_offscreen| | 414 true); // |adjust_if_offscreen| |
| 413 EXPECT_EQ(BubbleBorder::RIGHT_CENTER, frame.bubble_border()->arrow()); | 415 EXPECT_EQ(BubbleBorder::RIGHT_CENTER, frame.bubble_border()->arrow()); |
| 414 EXPECT_EQ(window_bounds.bottom(), 1000); | 416 EXPECT_EQ(window_bounds.bottom(), 1000); |
| 415 EXPECT_EQ(window_bounds.y() + | 417 EXPECT_EQ(window_bounds.y() + |
| 416 frame.bubble_border()->GetArrowOffset(window_bounds.size()), 925); | 418 frame.bubble_border()->GetArrowOffset(window_bounds.size()), 925); |
| 417 } | 419 } |
| 418 | 420 |
| 419 TEST_F(BubbleFrameViewTest, GetPreferredSize) { | 421 TEST_F(BubbleFrameViewTest, GetPreferredSize) { |
| 420 TestBubbleFrameView frame(this); | 422 TestBubbleFrameView frame(this); |
| 421 gfx::Size preferred_size = frame.GetPreferredSize(); | 423 gfx::Rect preferred_rect(frame.GetPreferredSize()); |
| 422 // Expect that a border has been added to the preferred size. | 424 // Expect that a border has been added to the preferred size. |
| 423 EXPECT_EQ(kPreferredClientWidth + kExpectedBorderWidth, | 425 preferred_rect.Inset(frame.bubble_border()->GetInsets()); |
|
msw
2016/03/14 17:16:25
So this ignores the bubble border size? (gets fram
karandeepb
2016/03/14 23:35:39
Yeah. Either the bubble border insets can be "adde
| |
| 424 preferred_size.width()); | 426 |
| 425 EXPECT_EQ(kPreferredClientHeight + kExpectedBorderHeight, | 427 gfx::Size expected_size(kPreferredClientWidth + kExpectedBorderWidth, |
| 426 preferred_size.height()); | 428 kPreferredClientHeight + kExpectedBorderHeight); |
| 429 EXPECT_EQ(expected_size, preferred_rect.size()); | |
| 427 } | 430 } |
| 428 | 431 |
| 429 TEST_F(BubbleFrameViewTest, GetMinimumSize) { | 432 TEST_F(BubbleFrameViewTest, GetMinimumSize) { |
| 430 TestBubbleFrameView frame(this); | 433 TestBubbleFrameView frame(this); |
| 431 gfx::Size minimum_size = frame.GetMinimumSize(); | 434 gfx::Rect minimum_rect(frame.GetMinimumSize()); |
| 432 // Expect that a border has been added to the minimum size. | 435 // Expect that a border has been added to the minimum size. |
| 433 EXPECT_EQ(kMinimumClientWidth + kExpectedBorderWidth, minimum_size.width()); | 436 minimum_rect.Inset(frame.bubble_border()->GetInsets()); |
| 434 EXPECT_EQ(kMinimumClientHeight + kExpectedBorderHeight, | 437 |
| 435 minimum_size.height()); | 438 gfx::Size expected_size(kMinimumClientWidth + kExpectedBorderWidth, |
| 439 kMinimumClientHeight + kExpectedBorderHeight); | |
| 440 EXPECT_EQ(expected_size, minimum_rect.size()); | |
| 436 } | 441 } |
| 437 | 442 |
| 438 TEST_F(BubbleFrameViewTest, GetMaximumSize) { | 443 TEST_F(BubbleFrameViewTest, GetMaximumSize) { |
| 439 TestBubbleFrameView frame(this); | 444 TestBubbleFrameView frame(this); |
| 440 gfx::Size maximum_size = frame.GetMaximumSize(); | 445 gfx::Rect maximum_rect(frame.GetMaximumSize()); |
| 441 #if defined(OS_WIN) | 446 #if defined(OS_WIN) |
| 442 // On Windows, GetMaximumSize causes problems with DWM, so it should just be 0 | 447 // On Windows, GetMaximumSize causes problems with DWM, so it should just be 0 |
| 443 // (unlimited). See http://crbug.com/506206. | 448 // (unlimited). See http://crbug.com/506206. |
| 444 EXPECT_EQ(0, maximum_size.width()); | 449 EXPECT_EQ(gfx::Size(), maximum_rect.size()); |
| 445 EXPECT_EQ(0, maximum_size.height()); | |
| 446 #else | 450 #else |
| 451 maximum_rect.Inset(frame.bubble_border()->GetInsets()); | |
| 452 | |
| 447 // Should ignore the contents view's maximum size and use the preferred size. | 453 // Should ignore the contents view's maximum size and use the preferred size. |
| 448 EXPECT_EQ(kPreferredClientWidth + kExpectedBorderWidth, maximum_size.width()); | 454 gfx::Size expected_size(kPreferredClientWidth + kExpectedBorderWidth, |
| 449 EXPECT_EQ(kPreferredClientHeight + kExpectedBorderHeight, | 455 kPreferredClientHeight + kExpectedBorderHeight); |
| 450 maximum_size.height()); | 456 EXPECT_EQ(expected_size, maximum_rect.size()); |
| 451 #endif | 457 #endif |
| 452 } | 458 } |
| 453 | 459 |
| 454 } // namespace views | 460 } // namespace views |
| OLD | NEW |