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

Side by Side Diff: ui/views/bubble/bubble_frame_view_unittest.cc

Issue 1774923002: MacViews: Fix failing bubble frame view tests after r375729. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review comments. Created 4 years, 9 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 // These account for non-client areas like the title bar, footnote etc. However
35 // these do not take the bubble border into consideration.
36 const int kExpectedAdditionalWidth = 12;
37 const int kExpectedAdditionalHeight = 12;
35 38
36 class TestBubbleFrameViewWidgetDelegate : public WidgetDelegate { 39 class TestBubbleFrameViewWidgetDelegate : public WidgetDelegate {
37 public: 40 public:
38 TestBubbleFrameViewWidgetDelegate(Widget* widget) : widget_(widget) {} 41 TestBubbleFrameViewWidgetDelegate(Widget* widget) : widget_(widget) {}
39 42
40 ~TestBubbleFrameViewWidgetDelegate() override {} 43 ~TestBubbleFrameViewWidgetDelegate() override {}
41 44
42 // WidgetDelegate overrides: 45 // WidgetDelegate overrides:
43 Widget* GetWidget() override { return widget_; } 46 Widget* GetWidget() override { return widget_; }
44 const Widget* GetWidget() const override { return widget_; } 47 const Widget* GetWidget() const override { return widget_; }
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 gfx::Size(500, 500), // |client_size| 413 gfx::Size(500, 500), // |client_size|
411 true); // |adjust_if_offscreen| 414 true); // |adjust_if_offscreen|
412 EXPECT_EQ(BubbleBorder::RIGHT_CENTER, frame.bubble_border()->arrow()); 415 EXPECT_EQ(BubbleBorder::RIGHT_CENTER, frame.bubble_border()->arrow());
413 EXPECT_EQ(window_bounds.bottom(), 1000); 416 EXPECT_EQ(window_bounds.bottom(), 1000);
414 EXPECT_EQ(window_bounds.y() + 417 EXPECT_EQ(window_bounds.y() +
415 frame.bubble_border()->GetArrowOffset(window_bounds.size()), 925); 418 frame.bubble_border()->GetArrowOffset(window_bounds.size()), 925);
416 } 419 }
417 420
418 TEST_F(BubbleFrameViewTest, GetPreferredSize) { 421 TEST_F(BubbleFrameViewTest, GetPreferredSize) {
419 TestBubbleFrameView frame(this); 422 TestBubbleFrameView frame(this);
420 gfx::Size preferred_size = frame.GetPreferredSize(); 423 gfx::Rect preferred_rect(frame.GetPreferredSize());
421 // Expect that a border has been added to the preferred size. 424 // Expect that a border has been added to the preferred size.
422 EXPECT_EQ(kPreferredClientWidth + kExpectedBorderWidth, 425 preferred_rect.Inset(frame.bubble_border()->GetInsets());
423 preferred_size.width()); 426
424 EXPECT_EQ(kPreferredClientHeight + kExpectedBorderHeight, 427 gfx::Size expected_size(kPreferredClientWidth + kExpectedAdditionalWidth,
425 preferred_size.height()); 428 kPreferredClientHeight + kExpectedAdditionalHeight);
429 EXPECT_EQ(expected_size, preferred_rect.size());
426 } 430 }
427 431
428 TEST_F(BubbleFrameViewTest, GetMinimumSize) { 432 TEST_F(BubbleFrameViewTest, GetMinimumSize) {
429 TestBubbleFrameView frame(this); 433 TestBubbleFrameView frame(this);
430 gfx::Size minimum_size = frame.GetMinimumSize(); 434 gfx::Rect minimum_rect(frame.GetMinimumSize());
431 // Expect that a border has been added to the minimum size. 435 // Expect that a border has been added to the minimum size.
432 EXPECT_EQ(kMinimumClientWidth + kExpectedBorderWidth, minimum_size.width()); 436 minimum_rect.Inset(frame.bubble_border()->GetInsets());
433 EXPECT_EQ(kMinimumClientHeight + kExpectedBorderHeight, 437
434 minimum_size.height()); 438 gfx::Size expected_size(kMinimumClientWidth + kExpectedAdditionalWidth,
439 kMinimumClientHeight + kExpectedAdditionalHeight);
440 EXPECT_EQ(expected_size, minimum_rect.size());
435 } 441 }
436 442
437 TEST_F(BubbleFrameViewTest, GetMaximumSize) { 443 TEST_F(BubbleFrameViewTest, GetMaximumSize) {
438 TestBubbleFrameView frame(this); 444 TestBubbleFrameView frame(this);
439 gfx::Size maximum_size = frame.GetMaximumSize(); 445 gfx::Rect maximum_rect(frame.GetMaximumSize());
440 #if defined(OS_WIN) 446 #if defined(OS_WIN)
441 // 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
442 // (unlimited). See http://crbug.com/506206. 448 // (unlimited). See http://crbug.com/506206.
443 EXPECT_EQ(0, maximum_size.width()); 449 EXPECT_EQ(gfx::Size(), maximum_rect.size());
444 EXPECT_EQ(0, maximum_size.height());
445 #else 450 #else
451 maximum_rect.Inset(frame.bubble_border()->GetInsets());
452
446 // 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.
447 EXPECT_EQ(kPreferredClientWidth + kExpectedBorderWidth, maximum_size.width()); 454 gfx::Size expected_size(kPreferredClientWidth + kExpectedAdditionalWidth,
448 EXPECT_EQ(kPreferredClientHeight + kExpectedBorderHeight, 455 kPreferredClientHeight + kExpectedAdditionalHeight);
449 maximum_size.height()); 456 EXPECT_EQ(expected_size, maximum_rect.size());
450 #endif 457 #endif
451 } 458 }
452 459
453 } // namespace views 460 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698