OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 "chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.h" | 5 #import "chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/strings/sys_string_conversions.h" | 8 #include "base/strings/sys_string_conversions.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" | 10 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" |
11 #import "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h" | 11 #import "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h" |
12 #include "chrome/test/base/testing_profile.h" | 12 #include "chrome/test/base/testing_profile.h" |
13 #include "components/omnibox/autocomplete_input.h" | 13 #include "components/omnibox/autocomplete_input.h" |
14 #include "components/omnibox/mock_autocomplete_provider_client.h" | |
14 #include "ui/gfx/font_list.h" | 15 #include "ui/gfx/font_list.h" |
15 #include "ui/gfx/geometry/rect.h" | 16 #include "ui/gfx/geometry/rect.h" |
16 #include "ui/gfx/text_elider.h" | 17 #include "ui/gfx/text_elider.h" |
17 | 18 |
18 namespace { | 19 namespace { |
19 | 20 |
20 class MockOmniboxPopupViewMac : public OmniboxPopupViewMac { | 21 class MockOmniboxPopupViewMac : public OmniboxPopupViewMac { |
21 public: | 22 public: |
22 MockOmniboxPopupViewMac(OmniboxView* omnibox_view, | 23 MockOmniboxPopupViewMac(OmniboxView* omnibox_view, |
23 OmniboxEditModel* edit_model, | 24 OmniboxEditModel* edit_model, |
24 NSTextField* field) | 25 NSTextField* field) |
25 : OmniboxPopupViewMac(omnibox_view, edit_model, field) { | 26 : OmniboxPopupViewMac(omnibox_view, edit_model, field), |
27 client_(new MockAutocompleteProviderClient()), | |
28 result_(client_.get()) { | |
26 } | 29 } |
27 | 30 |
28 void SetResultCount(size_t count) { | 31 void SetResultCount(size_t count) { |
29 ACMatches matches; | 32 ACMatches matches; |
30 for (size_t i = 0; i < count; ++i) | 33 for (size_t i = 0; i < count; ++i) |
31 matches.push_back(AutocompleteMatch()); | 34 matches.push_back(AutocompleteMatch()); |
32 result_.Reset(); | 35 result_.Reset(); |
33 result_.AppendMatches(AutocompleteInput(), matches); | 36 result_.AppendMatches(AutocompleteInput(), matches); |
34 } | 37 } |
35 | 38 |
36 protected: | 39 protected: |
37 const AutocompleteResult& GetResult() const override { return result_; } | 40 const AutocompleteResult& GetResult() const override { return result_; } |
38 | 41 |
39 private: | 42 private: |
43 scoped_ptr<AutocompleteProviderClient> client_; | |
Peter Kasting
2015/06/29 05:04:58
Nit: Again, can this drop the scoped_ptr?
Mark P
2015/06/30 04:23:17
Now moot.
| |
40 AutocompleteResult result_; | 44 AutocompleteResult result_; |
41 }; | 45 }; |
42 | 46 |
43 class OmniboxPopupViewMacTest : public CocoaProfileTest { | 47 class OmniboxPopupViewMacTest : public CocoaProfileTest { |
44 public: | 48 public: |
45 OmniboxPopupViewMacTest() {} | 49 OmniboxPopupViewMacTest() {} |
46 | 50 |
47 private: | 51 private: |
48 DISALLOW_COPY_AND_ASSIGN(OmniboxPopupViewMacTest); | 52 DISALLOW_COPY_AND_ASSIGN(OmniboxPopupViewMacTest); |
49 }; | 53 }; |
(...skipping 21 matching lines...) Expand all Loading... | |
71 EXPECT_GT(popup_view.GetTargetBounds().height(), old_height); | 75 EXPECT_GT(popup_view.GetTargetBounds().height(), old_height); |
72 EXPECT_EQ(5, [popup_view.matrix() numberOfRows]); | 76 EXPECT_EQ(5, [popup_view.matrix() numberOfRows]); |
73 | 77 |
74 popup_view.SetResultCount(0); | 78 popup_view.SetResultCount(0); |
75 popup_view.UpdatePopupAppearance(); | 79 popup_view.UpdatePopupAppearance(); |
76 EXPECT_FALSE(popup_view.IsOpen()); | 80 EXPECT_FALSE(popup_view.IsOpen()); |
77 EXPECT_EQ(0, [popup_view.matrix() numberOfRows]); | 81 EXPECT_EQ(0, [popup_view.matrix() numberOfRows]); |
78 } | 82 } |
79 | 83 |
80 } // namespace | 84 } // namespace |
OLD | NEW |