1 // Copyright (c) 2012 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.
5 #ifndef CHROME_BROWSER_UI_COCOA_AUTOCOMPLETE_TEXT_FIELD_UNITTEST_HELPER_H_
6 #define CHROME_BROWSER_UI_COCOA_AUTOCOMPLETE_TEXT_FIELD_UNITTEST_HELPER_H_
8 #import <Cocoa/Cocoa.h>
10 #include "base/mac/scoped_nsobject.h"
11 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.h"
12 #include "testing/gmock/include/gmock/gmock.h"
14 @
class AutocompleteTextFieldEditor
;
16 // Return the right field editor for AutocompleteTextField instance.
18 @interface AutocompleteTextFieldWindowTestDelegate
:
19 NSObject
<NSWindowDelegate
> {
20 base::scoped_nsobject
<AutocompleteTextFieldEditor
> editor_
;
22 - (id
)windowWillReturnFieldEditor
:(NSWindow
*)sender toObject
:(id
)anObject
;
25 // Allow monitoring calls into AutocompleteTextField's observer.
26 // Being in a .h file with an anonymous namespace is strange, but this
27 // is here so the mock interface doesn't have to change in multiple
30 // Any method you add here needs a unit test. You knew that.
32 class MockAutocompleteTextFieldObserver
: public AutocompleteTextFieldObserver
{
34 MockAutocompleteTextFieldObserver();
35 ~MockAutocompleteTextFieldObserver();
37 MOCK_METHOD1(SelectionRangeForProposedRange
, NSRange(NSRange range
));
38 MOCK_METHOD1(OnControlKeyChanged
, void(bool pressed
));
39 MOCK_METHOD0(CanCopy
, bool());
40 MOCK_METHOD1(CopyToPasteboard
, void(NSPasteboard
* pboard
));
41 MOCK_METHOD0(ShouldEnableShowURL
, bool());
42 MOCK_METHOD0(ShowURL
, void());
43 MOCK_METHOD0(OnPaste
, void());
44 MOCK_METHOD0(CanPasteAndGo
, bool());
45 MOCK_METHOD0(GetPasteActionStringId
, int());
46 MOCK_METHOD0(OnPasteAndGo
, void());
47 MOCK_METHOD0(OnFrameChanged
, void());
48 MOCK_METHOD0(ClosePopup
, void());
49 MOCK_METHOD0(OnDidBeginEditing
, void());
50 MOCK_METHOD0(OnBeforeChange
, void());
51 MOCK_METHOD0(OnDidChange
, void());
52 MOCK_METHOD0(OnDidEndEditing
, void());
53 MOCK_METHOD1(OnDoCommandBySelector
, bool(SEL cmd
));
54 MOCK_METHOD1(OnSetFocus
, void(bool control_down
));
55 MOCK_METHOD0(OnKillFocus
, void());
56 MOCK_METHOD1(OnMouseDown
, void(NSInteger button_number
));
57 MOCK_METHOD0(ShouldSelectAllOnMouseDown
, bool());
60 #endif // CHROME_BROWSER_UI_COCOA_AUTOCOMPLETE_TEXT_FIELD_UNITTEST_HELPER_H_