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/memory/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 "grit/theme_resources.h" | 18 #include "grit/theme_resources.h" |
19 #include "testing/gmock/include/gmock/gmock.h" | 19 #include "testing/gmock/include/gmock/gmock.h" |
20 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
21 #include "testing/platform_test.h" | 21 #include "testing/platform_test.h" |
| 22 #import "third_party/ocmock/OCMock/OCMock.h" |
22 #include "third_party/ocmock/gtest_support.h" | 23 #include "third_party/ocmock/gtest_support.h" |
23 #import "third_party/ocmock/OCMock/OCMock.h" | |
24 #include "ui/base/resource/resource_bundle.h" | 24 #include "ui/base/resource/resource_bundle.h" |
25 | 25 |
26 using ::testing::Return; | 26 using ::testing::Return; |
27 using ::testing::StrictMock; | 27 using ::testing::StrictMock; |
28 using ::testing::_; | 28 using ::testing::_; |
29 | 29 |
30 namespace { | 30 namespace { |
31 | 31 |
32 // 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 |
33 // the time. | 33 // the time. |
(...skipping 10 matching lines...) Expand all Loading... |
44 MOCK_METHOD0(GetToolTip, NSString*()); | 44 MOCK_METHOD0(GetToolTip, NSString*()); |
45 }; | 45 }; |
46 | 46 |
47 class AutocompleteTextFieldCellTest : public CocoaTest { | 47 class AutocompleteTextFieldCellTest : public CocoaTest { |
48 public: | 48 public: |
49 AutocompleteTextFieldCellTest() { | 49 AutocompleteTextFieldCellTest() { |
50 // Make sure this is wide enough to play games with the cell | 50 // Make sure this is wide enough to play games with the cell |
51 // decorations. | 51 // decorations. |
52 const NSRect frame = NSMakeRect(0, 0, kWidth, 30); | 52 const NSRect frame = NSMakeRect(0, 0, kWidth, 30); |
53 | 53 |
54 scoped_nsobject<NSTextField> view( | 54 base::scoped_nsobject<NSTextField> view( |
55 [[NSTextField alloc] initWithFrame:frame]); | 55 [[NSTextField alloc] initWithFrame:frame]); |
56 view_ = view.get(); | 56 view_ = view.get(); |
57 | 57 |
58 scoped_nsobject<AutocompleteTextFieldCell> cell( | 58 base::scoped_nsobject<AutocompleteTextFieldCell> cell( |
59 [[AutocompleteTextFieldCell alloc] initTextCell:@"Testing"]); | 59 [[AutocompleteTextFieldCell alloc] initTextCell:@"Testing"]); |
60 [cell setEditable:YES]; | 60 [cell setEditable:YES]; |
61 [cell setBordered:YES]; | 61 [cell setBordered:YES]; |
62 | 62 |
63 [cell clearDecorations]; | 63 [cell clearDecorations]; |
64 mock_left_decoration_.SetVisible(false); | 64 mock_left_decoration_.SetVisible(false); |
65 [cell addLeftDecoration:&mock_left_decoration_]; | 65 [cell addLeftDecoration:&mock_left_decoration_]; |
66 mock_right_decoration0_.SetVisible(false); | 66 mock_right_decoration0_.SetVisible(false); |
67 mock_right_decoration1_.SetVisible(false); | 67 mock_right_decoration1_.SetVisible(false); |
68 [cell addRightDecoration:&mock_right_decoration0_]; | 68 [cell addRightDecoration:&mock_right_decoration0_]; |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 // |controlView| gets the tooltip for the left decoration. | 292 // |controlView| gets the tooltip for the left decoration. |
293 id controlView = [OCMockObject mockForClass:[AutocompleteTextField class]]; | 293 id controlView = [OCMockObject mockForClass:[AutocompleteTextField class]]; |
294 [[controlView expect] addToolTip:tooltip forRect:leftDecorationRect]; | 294 [[controlView expect] addToolTip:tooltip forRect:leftDecorationRect]; |
295 | 295 |
296 [cell updateToolTipsInRect:bounds ofView:controlView]; | 296 [cell updateToolTipsInRect:bounds ofView:controlView]; |
297 | 297 |
298 EXPECT_OCMOCK_VERIFY(controlView); | 298 EXPECT_OCMOCK_VERIFY(controlView); |
299 } | 299 } |
300 | 300 |
301 } // namespace | 301 } // namespace |
OLD | NEW |