| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "chrome/browser/ui/tabs/dock_info.h" | 6 #include "chrome/browser/ui/tabs/dock_info.h" |
| 7 #include "gfx/point.h" | 7 #include "gfx/point.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 | 9 |
| 10 namespace { | 10 namespace { |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 for (size_t i = 0; i < arraysize(expected_results); ++i) { | 94 for (size_t i = 0; i < arraysize(expected_results); ++i) { |
| 95 bool result = DockInfo::IsCloseToMonitorPoint( | 95 bool result = DockInfo::IsCloseToMonitorPoint( |
| 96 screen_loc[i], hotspot.x(), hotspot.y(), type[i], &in_enable_area); | 96 screen_loc[i], hotspot.x(), hotspot.y(), type[i], &in_enable_area); |
| 97 EXPECT_EQ(expected_results[i], result); | 97 EXPECT_EQ(expected_results[i], result); |
| 98 EXPECT_EQ(expected_in_enable_area[i], in_enable_area); | 98 EXPECT_EQ(expected_in_enable_area[i], in_enable_area); |
| 99 } | 99 } |
| 100 } | 100 } |
| 101 | 101 |
| 102 TEST(DockInfoTest, IsValidForPoint) { | 102 TEST(DockInfoTest, IsValidForPoint) { |
| 103 DockInfo d; | 103 DockInfo d; |
| 104 EXPECT_EQ(false, d.IsValidForPoint(gfx::Point(0, 0))); | 104 EXPECT_FALSE(d.IsValidForPoint(gfx::Point(0, 0))); |
| 105 d.set_monitor_bounds(gfx::Rect(0, 0, kPopupWidth, kPopupHeight)); | 105 d.set_monitor_bounds(gfx::Rect(0, 0, kPopupWidth, kPopupHeight)); |
| 106 d.set_hot_spot(gfx::Point(0, 0)); | 106 d.set_hot_spot(gfx::Point(0, 0)); |
| 107 d.set_type(DockInfo::LEFT_HALF); | 107 d.set_type(DockInfo::LEFT_HALF); |
| 108 | 108 |
| 109 gfx::Point screen_point[] = { | 109 gfx::Point screen_point[] = { |
| 110 gfx::Point(0, 0), | 110 gfx::Point(0, 0), |
| 111 gfx::Point(kPopupWidth + 1, kPopupHeight + 1), | 111 gfx::Point(kPopupWidth + 1, kPopupHeight + 1), |
| 112 gfx::Point(2 * kHotSpotDeltaX, kHotSpotDeltaY), | 112 gfx::Point(2 * kHotSpotDeltaX, kHotSpotDeltaY), |
| 113 }; | 113 }; |
| 114 | 114 |
| 115 bool expected_result[] = { | 115 bool expected_result[] = { |
| 116 true, false, false | 116 true, false, false |
| 117 }; | 117 }; |
| 118 | 118 |
| 119 for (size_t i = 0; i < arraysize(expected_result); ++i) { | 119 for (size_t i = 0; i < arraysize(expected_result); ++i) { |
| 120 EXPECT_EQ(expected_result[i], d.IsValidForPoint(screen_point[i])); | 120 EXPECT_EQ(expected_result[i], d.IsValidForPoint(screen_point[i])); |
| 121 } | 121 } |
| 122 } | 122 } |
| 123 | 123 |
| 124 TEST(DockInfoTest, equals) { | 124 TEST(DockInfoTest, equals) { |
| 125 DockInfo d; | 125 DockInfo d; |
| 126 DockInfo dd; | 126 DockInfo dd; |
| 127 EXPECT_EQ(true, d.equals(dd)); | 127 EXPECT_TRUE(d.equals(dd)); |
| 128 d.set_type(DockInfo::MAXIMIZE); | 128 d.set_type(DockInfo::MAXIMIZE); |
| 129 EXPECT_EQ(false, d.equals(dd)); | 129 EXPECT_FALSE(d.equals(dd)); |
| 130 } | 130 } |
| 131 | 131 |
| 132 TEST(DockInfoTest, CheckMonitorPoint) { | 132 TEST(DockInfoTest, CheckMonitorPoint) { |
| 133 DockInfo d; | 133 DockInfo d; |
| 134 gfx::Point screen_loc[] = { | 134 gfx::Point screen_loc[] = { |
| 135 gfx::Point(0, 0), | 135 gfx::Point(0, 0), |
| 136 gfx::Point(2 * kHotSpotDeltaX, kHotSpotDeltaY), | 136 gfx::Point(2 * kHotSpotDeltaX, kHotSpotDeltaY), |
| 137 gfx::Point(2 * kHotSpotDeltaX, kHotSpotDeltaY), | 137 gfx::Point(2 * kHotSpotDeltaX, kHotSpotDeltaY), |
| 138 }; | 138 }; |
| 139 | 139 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 | 182 |
| 183 for (size_t i = 0; i < arraysize(type); ++i) { | 183 for (size_t i = 0; i < arraysize(type); ++i) { |
| 184 d.set_type(type[i]); | 184 d.set_type(type[i]); |
| 185 gfx::Rect result = d.GetPopupRect(); | 185 gfx::Rect result = d.GetPopupRect(); |
| 186 EXPECT_EQ(expected_x[i], result.x()); | 186 EXPECT_EQ(expected_x[i], result.x()); |
| 187 EXPECT_EQ(expected_y[i], result.y()); | 187 EXPECT_EQ(expected_y[i], result.y()); |
| 188 EXPECT_EQ(kPopupWidth, result.width()); | 188 EXPECT_EQ(kPopupWidth, result.width()); |
| 189 EXPECT_EQ(kPopupHeight, result.height()); | 189 EXPECT_EQ(kPopupHeight, result.height()); |
| 190 } | 190 } |
| 191 } | 191 } |
| OLD | NEW |