| 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" |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 AutocompleteTextFieldCell* cell = | 93 AutocompleteTextFieldCell* cell = |
| 94 static_cast<AutocompleteTextFieldCell*>([view_ cell]); | 94 static_cast<AutocompleteTextFieldCell*>([view_ cell]); |
| 95 | 95 |
| 96 // Load available decorations and try drawing. To make sure that | 96 // Load available decorations and try drawing. To make sure that |
| 97 // they are actually drawn, check that |GetWidthForSpace()| doesn't | 97 // they are actually drawn, check that |GetWidthForSpace()| doesn't |
| 98 // indicate that they should be omitted. | 98 // indicate that they should be omitted. |
| 99 const CGFloat kVeryWide = 1000.0; | 99 const CGFloat kVeryWide = 1000.0; |
| 100 | 100 |
| 101 SelectedKeywordDecoration selected_keyword_decoration; | 101 SelectedKeywordDecoration selected_keyword_decoration; |
| 102 selected_keyword_decoration.SetVisible(true); | 102 selected_keyword_decoration.SetVisible(true); |
| 103 selected_keyword_decoration.SetKeyword(ASCIIToUTF16("Google"), false); | 103 selected_keyword_decoration.SetKeyword(base::ASCIIToUTF16("Google"), false); |
| 104 [cell addLeftDecoration:&selected_keyword_decoration]; | 104 [cell addLeftDecoration:&selected_keyword_decoration]; |
| 105 EXPECT_NE(selected_keyword_decoration.GetWidthForSpace(kVeryWide), | 105 EXPECT_NE(selected_keyword_decoration.GetWidthForSpace(kVeryWide), |
| 106 LocationBarDecoration::kOmittedWidth); | 106 LocationBarDecoration::kOmittedWidth); |
| 107 | 107 |
| 108 // TODO(shess): This really wants a |LocationBarViewMac|, but only a | 108 // TODO(shess): This really wants a |LocationBarViewMac|, but only a |
| 109 // few methods reference it, so this works well enough. But | 109 // few methods reference it, so this works well enough. But |
| 110 // something better would be nice. | 110 // something better would be nice. |
| 111 LocationIconDecoration location_icon_decoration(NULL); | 111 LocationIconDecoration location_icon_decoration(NULL); |
| 112 location_icon_decoration.SetVisible(true); | 112 location_icon_decoration.SetVisible(true); |
| 113 location_icon_decoration.SetImage([NSImage imageNamed:@"NSApplicationIcon"]); | 113 location_icon_decoration.SetImage([NSImage imageNamed:@"NSApplicationIcon"]); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 124 LocationBarDecoration::kOmittedWidth); | 124 LocationBarDecoration::kOmittedWidth); |
| 125 | 125 |
| 126 StarDecoration star_decoration(NULL); | 126 StarDecoration star_decoration(NULL); |
| 127 star_decoration.SetVisible(true); | 127 star_decoration.SetVisible(true); |
| 128 [cell addRightDecoration:&star_decoration]; | 128 [cell addRightDecoration:&star_decoration]; |
| 129 EXPECT_NE(star_decoration.GetWidthForSpace(kVeryWide), | 129 EXPECT_NE(star_decoration.GetWidthForSpace(kVeryWide), |
| 130 LocationBarDecoration::kOmittedWidth); | 130 LocationBarDecoration::kOmittedWidth); |
| 131 | 131 |
| 132 KeywordHintDecoration keyword_hint_decoration; | 132 KeywordHintDecoration keyword_hint_decoration; |
| 133 keyword_hint_decoration.SetVisible(true); | 133 keyword_hint_decoration.SetVisible(true); |
| 134 keyword_hint_decoration.SetKeyword(ASCIIToUTF16("google"), false); | 134 keyword_hint_decoration.SetKeyword(base::ASCIIToUTF16("google"), false); |
| 135 [cell addRightDecoration:&keyword_hint_decoration]; | 135 [cell addRightDecoration:&keyword_hint_decoration]; |
| 136 EXPECT_NE(keyword_hint_decoration.GetWidthForSpace(kVeryWide), | 136 EXPECT_NE(keyword_hint_decoration.GetWidthForSpace(kVeryWide), |
| 137 LocationBarDecoration::kOmittedWidth); | 137 LocationBarDecoration::kOmittedWidth); |
| 138 | 138 |
| 139 // Make sure we're actually calling |DrawInFrame()|. | 139 // Make sure we're actually calling |DrawInFrame()|. |
| 140 StrictMock<MockDecoration> mock_decoration; | 140 StrictMock<MockDecoration> mock_decoration; |
| 141 mock_decoration.SetVisible(true); | 141 mock_decoration.SetVisible(true); |
| 142 [cell addLeftDecoration:&mock_decoration]; | 142 [cell addLeftDecoration:&mock_decoration]; |
| 143 EXPECT_CALL(mock_decoration, DrawInFrame(_, _)); | 143 EXPECT_CALL(mock_decoration, DrawInFrame(_, _)); |
| 144 EXPECT_NE(mock_decoration.GetWidthForSpace(kVeryWide), | 144 EXPECT_NE(mock_decoration.GetWidthForSpace(kVeryWide), |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 // |controlView| gets the tooltip for the left decoration. | 289 // |controlView| gets the tooltip for the left decoration. |
| 290 id controlView = [OCMockObject mockForClass:[AutocompleteTextField class]]; | 290 id controlView = [OCMockObject mockForClass:[AutocompleteTextField class]]; |
| 291 [[controlView expect] addToolTip:tooltip forRect:leftDecorationRect]; | 291 [[controlView expect] addToolTip:tooltip forRect:leftDecorationRect]; |
| 292 | 292 |
| 293 [cell updateToolTipsInRect:bounds ofView:controlView]; | 293 [cell updateToolTipsInRect:bounds ofView:controlView]; |
| 294 | 294 |
| 295 EXPECT_OCMOCK_VERIFY(controlView); | 295 EXPECT_OCMOCK_VERIFY(controlView); |
| 296 } | 296 } |
| 297 | 297 |
| 298 } // namespace | 298 } // namespace |
| OLD | NEW |