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

Side by Side Diff: chrome/browser/devtools/devtools_contents_resizing_strategy_unittest.cc

Issue 137483007: [DevTools] Use special resizing strategy instead of insets. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed review comments Created 6 years, 10 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
(Empty)
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/devtools/devtools_contents_resizing_strategy.h"
6 #include "testing/gtest/include/gtest/gtest.h"
sky 2014/02/04 15:12:17 nit: newline between lines 5 and 6.
dgozman 2014/02/04 15:29:01 Done.
7
8 TEST(DevToolsContentsResizingStrategyTest, ApplyZero) {
9 DevToolsContentsResizingStrategy zeroStrategy;
10 gfx::Size container_size(100, 200);
11 gfx::Rect old_devtools_bounds(0, 0, 100, 200);
12 gfx::Rect old_contents_bounds(20, 20, 60, 140);
13 gfx::Rect new_devtools_bounds;
14 gfx::Rect new_contents_bounds;
15 ApplyDevToolsContentsResizingStrategy(
16 zeroStrategy, container_size,
17 old_devtools_bounds, old_contents_bounds,
18 &new_devtools_bounds, &new_contents_bounds);
19 EXPECT_EQ(gfx::Rect(0, 0, 100, 200), new_devtools_bounds);
20 EXPECT_EQ(gfx::Rect(0, 0, 100, 200), new_contents_bounds);
21 }
22
23 TEST(DevToolsContentsResizingStrategyTest, ApplyInsets) {
24 DevToolsContentsResizingStrategy strategy(
25 gfx::Insets(10, 20, 30, 40), gfx::Size(0, 0));
26 gfx::Size container_size(100, 200);
27 gfx::Rect old_devtools_bounds(0, 0, 100, 200);
28 gfx::Rect old_contents_bounds(20, 20, 60, 140);
29 gfx::Rect new_devtools_bounds;
30 gfx::Rect new_contents_bounds;
31 ApplyDevToolsContentsResizingStrategy(
32 strategy, container_size,
33 old_devtools_bounds, old_contents_bounds,
34 &new_devtools_bounds, &new_contents_bounds);
35 EXPECT_EQ(gfx::Rect(0, 0, 100, 200), new_devtools_bounds);
36 EXPECT_EQ(gfx::Rect(20, 10, 40, 160), new_contents_bounds);
37 }
38
39 TEST(DevToolsContentsResizingStrategyTest, ApplyMinSize) {
40 DevToolsContentsResizingStrategy strategy(
41 gfx::Insets(10, 20, 90, 30), gfx::Size(60, 120));
42 gfx::Size container_size(100, 200);
43 gfx::Rect old_devtools_bounds(0, 0, 100, 200);
44 gfx::Rect old_contents_bounds(20, 20, 60, 140);
45 gfx::Rect new_devtools_bounds;
46 gfx::Rect new_contents_bounds;
47 ApplyDevToolsContentsResizingStrategy(
48 strategy, container_size,
49 old_devtools_bounds, old_contents_bounds,
50 &new_devtools_bounds, &new_contents_bounds);
51 EXPECT_EQ(gfx::Rect(0, 0, 100, 200), new_devtools_bounds);
52 EXPECT_EQ(gfx::Rect(16, 8, 60, 120), new_contents_bounds);
53 }
54
55 TEST(DevToolsContentsResizingStrategyTest, ApplyLargeInset) {
56 DevToolsContentsResizingStrategy strategy(
57 gfx::Insets(0, 130, 0, 0), gfx::Size(60, 120));
58 gfx::Size container_size(100, 200);
59 gfx::Rect old_devtools_bounds(0, 0, 100, 200);
60 gfx::Rect old_contents_bounds(20, 20, 60, 140);
61 gfx::Rect new_devtools_bounds;
62 gfx::Rect new_contents_bounds;
63 ApplyDevToolsContentsResizingStrategy(
64 strategy, container_size,
65 old_devtools_bounds, old_contents_bounds,
66 &new_devtools_bounds, &new_contents_bounds);
67 EXPECT_EQ(gfx::Rect(0, 0, 100, 200), new_devtools_bounds);
68 EXPECT_EQ(gfx::Rect(40, 0, 60, 200), new_contents_bounds);
69 }
70
71 TEST(DevToolsContentsResizingStrategyTest, ApplyTwoLargeInsets) {
72 DevToolsContentsResizingStrategy strategy(
73 gfx::Insets(120, 0, 80, 0), gfx::Size(60, 120));
74 gfx::Size container_size(100, 200);
75 gfx::Rect old_devtools_bounds(0, 0, 100, 200);
76 gfx::Rect old_contents_bounds(20, 20, 60, 140);
77 gfx::Rect new_devtools_bounds;
78 gfx::Rect new_contents_bounds;
79 ApplyDevToolsContentsResizingStrategy(
80 strategy, container_size,
81 old_devtools_bounds, old_contents_bounds,
82 &new_devtools_bounds, &new_contents_bounds);
83 EXPECT_EQ(gfx::Rect(0, 0, 100, 200), new_devtools_bounds);
84 EXPECT_EQ(gfx::Rect(0, 48, 100, 120), new_contents_bounds);
85 }
86
87 TEST(DevToolsContentsResizingStrategyTest, ApplySmallContainer) {
88 DevToolsContentsResizingStrategy strategy(
89 gfx::Insets(10, 10, 10, 10), gfx::Size(120, 230));
90 gfx::Size container_size(100, 200);
91 gfx::Rect old_devtools_bounds(0, 0, 100, 200);
92 gfx::Rect old_contents_bounds(20, 20, 60, 140);
93 gfx::Rect new_devtools_bounds;
94 gfx::Rect new_contents_bounds;
95 ApplyDevToolsContentsResizingStrategy(
96 strategy, container_size,
97 old_devtools_bounds, old_contents_bounds,
98 &new_devtools_bounds, &new_contents_bounds);
99 EXPECT_EQ(gfx::Rect(0, 0, 100, 200), new_devtools_bounds);
100 EXPECT_EQ(gfx::Rect(0, 0, 100, 200), new_contents_bounds);
101 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698