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

Side by Side Diff: ui/gfx/geometry/rect_unittest.cc

Issue 2749513011: Stabilize empty rect handling in EnclosingRect. (Closed)
Patch Set: Use size in Enclosing computation Created 3 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 <limits> 5 #include <limits>
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 float y1; 526 float y1;
527 float w1; 527 float w1;
528 float h1; 528 float h1;
529 int x2; // target 529 int x2; // target
530 int y2; 530 int y2;
531 int w2; 531 int w2;
532 int h2; 532 int h2;
533 } tests[] = { 533 } tests[] = {
534 {0.0f, 0.0f, 0.0f, 0.0f, 0, 0, 0, 0}, 534 {0.0f, 0.0f, 0.0f, 0.0f, 0, 0, 0, 0},
535 {5.5f, 5.5f, 0.0f, 0.0f, 5, 5, 0, 0}, 535 {5.5f, 5.5f, 0.0f, 0.0f, 5, 5, 0, 0},
536 {3.5f, 2.5f, 0.01f, -0.0f, 3, 2, 0, 0},
536 {-1.5f, -1.5f, 3.0f, 3.0f, -2, -2, 4, 4}, 537 {-1.5f, -1.5f, 3.0f, 3.0f, -2, -2, 4, 4},
537 {-1.5f, -1.5f, 3.5f, 3.5f, -2, -2, 4, 4}, 538 {-1.5f, -1.5f, 3.5f, 3.5f, -2, -2, 4, 4},
538 {max_float, max_float, 2.0f, 2.0f, max_int, max_int, 0, 0}, 539 {max_float, max_float, 2.0f, 2.0f, max_int, max_int, 0, 0},
539 {0.0f, 0.0f, max_float, max_float, 0, 0, max_int, max_int}, 540 {0.0f, 0.0f, max_float, max_float, 0, 0, max_int, max_int},
540 {20000.5f, 20000.5f, 0.5f, 0.5f, 20000, 20000, 1, 1}, 541 {20000.5f, 20000.5f, 0.5f, 0.5f, 20000, 20000, 1, 1},
541 {static_cast<float>(min_int), static_cast<float>(min_int), max_int * 2.f, 542 {static_cast<float>(min_int), static_cast<float>(min_int), max_int * 2.f,
542 max_int * 2.f, min_int, min_int, max_int, max_int}, 543 max_int * 2.f, min_int, min_int, max_int, max_int},
543 {static_cast<float>(max_int), static_cast<float>(max_int), 544 {static_cast<float>(max_int), static_cast<float>(max_int),
544 static_cast<float>(max_int), static_cast<float>(max_int), max_int, 545 static_cast<float>(max_int), static_cast<float>(max_int), max_int,
545 max_int, 0, 0}, 546 max_int, 0, 0},
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after
1090 1091
1091 Rect min_rect(min_int, min_int, max_int, max_int); 1092 Rect min_rect(min_int, min_int, max_int, max_int);
1092 // Min rect can't be scaled up any further in any dimension. 1093 // Min rect can't be scaled up any further in any dimension.
1093 EXPECT_EQ(ScaleToEnclosingRectSafe(min_rect, 2, 3.5), min_rect); 1094 EXPECT_EQ(ScaleToEnclosingRectSafe(min_rect, 2, 3.5), min_rect);
1094 EXPECT_EQ(ScaleToEnclosingRectSafe(min_rect, max_int, max_int), min_rect); 1095 EXPECT_EQ(ScaleToEnclosingRectSafe(min_rect, max_int, max_int), min_rect);
1095 // Min rect scaled by min is an empty rect at (max, max) 1096 // Min rect scaled by min is an empty rect at (max, max)
1096 EXPECT_EQ(ScaleToEnclosingRectSafe(min_rect, min_int, min_int), max_rect); 1097 EXPECT_EQ(ScaleToEnclosingRectSafe(min_rect, min_int, min_int), max_rect);
1097 } 1098 }
1098 1099
1099 } // namespace gfx 1100 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698