| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #import <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
| 6 | 6 |
| 7 #include "base/mac/scoped_nsobject.h" | 7 #include "base/mac/scoped_nsobject.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" | 9 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" |
| 10 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.h" | 10 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.h" |
| 11 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.h" | 11 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.h" |
| 12 #import "chrome/browser/ui/cocoa/location_bar/ev_bubble_decoration.h" | 12 #import "chrome/browser/ui/cocoa/location_bar/ev_bubble_decoration.h" |
| 13 #import "chrome/browser/ui/cocoa/location_bar/keyword_hint_decoration.h" | 13 #import "chrome/browser/ui/cocoa/location_bar/keyword_hint_decoration.h" |
| 14 #import "chrome/browser/ui/cocoa/location_bar/location_bar_decoration.h" | 14 #import "chrome/browser/ui/cocoa/location_bar/location_bar_decoration.h" |
| 15 #import "chrome/browser/ui/cocoa/location_bar/location_icon_decoration.h" | 15 #import "chrome/browser/ui/cocoa/location_bar/location_icon_decoration.h" |
| 16 #import "chrome/browser/ui/cocoa/location_bar/selected_keyword_decoration.h" | 16 #import "chrome/browser/ui/cocoa/location_bar/selected_keyword_decoration.h" |
| 17 #import "chrome/browser/ui/cocoa/location_bar/star_decoration.h" | 17 #import "chrome/browser/ui/cocoa/location_bar/star_decoration.h" |
| 18 #include "testing/gmock/include/gmock/gmock.h" | 18 #include "testing/gmock/include/gmock/gmock.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 20 #import "testing/gtest_mac.h" | 20 #import "testing/gtest_mac.h" |
| 21 #include "testing/platform_test.h" | 21 #include "testing/platform_test.h" |
| 22 #import "third_party/ocmock/OCMock/OCMock.h" | 22 #import "third_party/ocmock/OCMock/OCMock.h" |
| 23 #include "third_party/ocmock/gtest_support.h" | 23 #include "third_party/ocmock/gtest_support.h" |
| 24 #include "ui/base/material_design/material_design_controller.h" |
| 24 | 25 |
| 25 using ::testing::Return; | 26 using ::testing::Return; |
| 26 using ::testing::StrictMock; | 27 using ::testing::StrictMock; |
| 27 using ::testing::_; | 28 using ::testing::_; |
| 28 | 29 |
| 29 namespace { | 30 namespace { |
| 30 | 31 |
| 31 // Width of the field so that we don't have to ask |field_| for it all | 32 // Width of the field so that we don't have to ask |field_| for it all |
| 32 // the time. | 33 // the time. |
| 33 const CGFloat kWidth(300.0); | 34 const CGFloat kWidth(300.0); |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 NSRect textFrame; | 156 NSRect textFrame; |
| 156 | 157 |
| 157 // The cursor frame should stay the same throughout. | 158 // The cursor frame should stay the same throughout. |
| 158 const NSRect cursorFrame([cell textCursorFrameForFrame:bounds]); | 159 const NSRect cursorFrame([cell textCursorFrameForFrame:bounds]); |
| 159 EXPECT_NSEQ(cursorFrame, bounds); | 160 EXPECT_NSEQ(cursorFrame, bounds); |
| 160 | 161 |
| 161 // At default settings, everything goes to the text area. | 162 // At default settings, everything goes to the text area. |
| 162 textFrame = [cell textFrameForFrame:bounds]; | 163 textFrame = [cell textFrameForFrame:bounds]; |
| 163 EXPECT_FALSE(NSIsEmptyRect(textFrame)); | 164 EXPECT_FALSE(NSIsEmptyRect(textFrame)); |
| 164 EXPECT_TRUE(NSContainsRect(bounds, textFrame)); | 165 EXPECT_TRUE(NSContainsRect(bounds, textFrame)); |
| 165 EXPECT_EQ(NSMinX(bounds), NSMinX(textFrame)); | 166 if (ui::MaterialDesignController::IsModeMaterial()) { |
| 167 EXPECT_EQ(1, NSMinX(textFrame)); |
| 168 } else { |
| 169 EXPECT_EQ(NSMinX(bounds), NSMinX(textFrame)); |
| 170 } |
| 166 EXPECT_EQ(NSMaxX(bounds), NSMaxX(textFrame)); | 171 EXPECT_EQ(NSMaxX(bounds), NSMaxX(textFrame)); |
| 167 EXPECT_TRUE(NSContainsRect(cursorFrame, textFrame)); | 172 EXPECT_TRUE(NSContainsRect(cursorFrame, textFrame)); |
| 168 | 173 |
| 169 // Decoration on the left takes up space. | 174 // Decoration on the left takes up space. |
| 170 mock_left_decoration_.SetVisible(true); | 175 mock_left_decoration_.SetVisible(true); |
| 171 textFrame = [cell textFrameForFrame:bounds]; | 176 textFrame = [cell textFrameForFrame:bounds]; |
| 172 EXPECT_FALSE(NSIsEmptyRect(textFrame)); | 177 EXPECT_FALSE(NSIsEmptyRect(textFrame)); |
| 173 EXPECT_TRUE(NSContainsRect(bounds, textFrame)); | 178 EXPECT_TRUE(NSContainsRect(bounds, textFrame)); |
| 174 EXPECT_GT(NSMinX(textFrame), NSMinX(bounds)); | 179 EXPECT_GT(NSMinX(textFrame), NSMinX(bounds)); |
| 175 EXPECT_TRUE(NSContainsRect(cursorFrame, textFrame)); | 180 EXPECT_TRUE(NSContainsRect(cursorFrame, textFrame)); |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 // |controlView| gets the tooltip for the left decoration. | 293 // |controlView| gets the tooltip for the left decoration. |
| 289 id controlView = [OCMockObject mockForClass:[AutocompleteTextField class]]; | 294 id controlView = [OCMockObject mockForClass:[AutocompleteTextField class]]; |
| 290 [[controlView expect] addToolTip:tooltip forRect:leftDecorationRect]; | 295 [[controlView expect] addToolTip:tooltip forRect:leftDecorationRect]; |
| 291 | 296 |
| 292 [cell updateToolTipsInRect:bounds ofView:controlView]; | 297 [cell updateToolTipsInRect:bounds ofView:controlView]; |
| 293 | 298 |
| 294 EXPECT_OCMOCK_VERIFY(controlView); | 299 EXPECT_OCMOCK_VERIFY(controlView); |
| 295 } | 300 } |
| 296 | 301 |
| 297 } // namespace | 302 } // namespace |
| OLD | NEW |