Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(652)

Side by Side Diff: chrome/browser/ui/cocoa/omnibox/omnibox_view_mac_unittest.mm

Issue 1653013002: Abstract ToolbarModelImpl dependencies on //content. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@1
Patch Set: Address comments Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_view_mac.h" 5 #import "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" 10 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h"
11 #include "chrome/browser/ui/omnibox/chrome_omnibox_client.h" 11 #include "chrome/browser/ui/omnibox/chrome_omnibox_client.h"
12 #include "chrome/browser/ui/omnibox/chrome_omnibox_edit_controller.h" 12 #include "chrome/browser/ui/omnibox/chrome_omnibox_edit_controller.h"
13 #include "chrome/browser/ui/toolbar/chrome_toolbar_model_delegate.h" 13 #include "chrome/browser/ui/toolbar/chrome_toolbar_model_delegate.h"
14 #include "chrome/browser/ui/toolbar/toolbar_model_impl.h" 14 #include "chrome/browser/ui/toolbar/toolbar_model_impl.h"
15 #include "chrome/test/base/testing_profile.h" 15 #include "chrome/test/base/testing_profile.h"
16 #include "components/omnibox/browser/omnibox_popup_model.h" 16 #include "components/omnibox/browser/omnibox_popup_model.h"
17 #include "components/omnibox/browser/omnibox_popup_view.h" 17 #include "components/omnibox/browser/omnibox_popup_view.h"
18 #include "content/public/common/content_constants.h"
18 #include "testing/platform_test.h" 19 #include "testing/platform_test.h"
19 #include "ui/gfx/font.h" 20 #include "ui/gfx/font.h"
20 #include "ui/gfx/geometry/rect.h" 21 #include "ui/gfx/geometry/rect.h"
21 #include "ui/gfx/image/image.h" 22 #include "ui/gfx/image/image.h"
22 23
23 namespace { 24 namespace {
24 25
25 class MockOmniboxEditModel : public OmniboxEditModel { 26 class MockOmniboxEditModel : public OmniboxEditModel {
26 public: 27 public:
27 MockOmniboxEditModel(OmniboxView* view, 28 MockOmniboxEditModel(OmniboxView* view,
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 bool is_open_; 68 bool is_open_;
68 69
69 DISALLOW_COPY_AND_ASSIGN(MockOmniboxPopupView); 70 DISALLOW_COPY_AND_ASSIGN(MockOmniboxPopupView);
70 }; 71 };
71 72
72 class TestingToolbarModelDelegate : public ChromeToolbarModelDelegate { 73 class TestingToolbarModelDelegate : public ChromeToolbarModelDelegate {
73 public: 74 public:
74 TestingToolbarModelDelegate() {} 75 TestingToolbarModelDelegate() {}
75 ~TestingToolbarModelDelegate() override {} 76 ~TestingToolbarModelDelegate() override {}
76 77
77 // Overridden from ToolbarModelDelegate: 78 // Overridden from ChromeToolbarModelDelegate:
78 content::WebContents* GetActiveWebContents() const override { return NULL; } 79 content::WebContents* GetActiveWebContents() const override { return NULL; }
79 80
80 private: 81 private:
81 DISALLOW_COPY_AND_ASSIGN(TestingToolbarModelDelegate); 82 DISALLOW_COPY_AND_ASSIGN(TestingToolbarModelDelegate);
82 }; 83 };
83 84
84 class TestingOmniboxEditController : public ChromeOmniboxEditController { 85 class TestingOmniboxEditController : public ChromeOmniboxEditController {
85 public: 86 public:
86 explicit TestingOmniboxEditController(ToolbarModel* toolbar_model) 87 explicit TestingOmniboxEditController(ToolbarModel* toolbar_model)
87 : ChromeOmniboxEditController(NULL), toolbar_model_(toolbar_model) {} 88 : ChromeOmniboxEditController(NULL), toolbar_model_(toolbar_model) {}
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 view.OnDoCommandBySelector(@selector(insertBacktab:)); 144 view.OnDoCommandBySelector(@selector(insertBacktab:));
144 EXPECT_EQ(-1, model->up_or_down_count()); 145 EXPECT_EQ(-1, model->up_or_down_count());
145 } 146 }
146 147
147 TEST_F(OmniboxViewMacTest, SetGrayTextAutocompletion) { 148 TEST_F(OmniboxViewMacTest, SetGrayTextAutocompletion) {
148 const NSRect frame = NSMakeRect(0, 0, 50, 30); 149 const NSRect frame = NSMakeRect(0, 0, 50, 30);
149 base::scoped_nsobject<AutocompleteTextField> field( 150 base::scoped_nsobject<AutocompleteTextField> field(
150 [[AutocompleteTextField alloc] initWithFrame:frame]); 151 [[AutocompleteTextField alloc] initWithFrame:frame]);
151 152
152 TestingToolbarModelDelegate delegate; 153 TestingToolbarModelDelegate delegate;
153 ToolbarModelImpl toolbar_model(&delegate); 154 ToolbarModelImpl toolbar_model(&delegate, content::kMaxURLDisplayChars);
154 TestingOmniboxEditController controller(&toolbar_model); 155 TestingOmniboxEditController controller(&toolbar_model);
155 OmniboxViewMac view(&controller, profile(), NULL, field.get()); 156 OmniboxViewMac view(&controller, profile(), NULL, field.get());
156 157
157 // This is deleted by the omnibox view. 158 // This is deleted by the omnibox view.
158 MockOmniboxEditModel* model = 159 MockOmniboxEditModel* model =
159 new MockOmniboxEditModel(&view, &controller, profile()); 160 new MockOmniboxEditModel(&view, &controller, profile());
160 SetModel(&view, model); 161 SetModel(&view, model);
161 162
162 MockOmniboxPopupView popup_view; 163 MockOmniboxPopupView popup_view;
163 OmniboxPopupModel popup_model(&popup_view, model); 164 OmniboxPopupModel popup_model(&popup_view, model);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 196
196 // With popup open verify that pressing up and down arrow works. 197 // With popup open verify that pressing up and down arrow works.
197 popup_view.set_is_open(true); 198 popup_view.set_is_open(true);
198 model->set_up_or_down_count(0); 199 model->set_up_or_down_count(0);
199 view.OnDoCommandBySelector(@selector(moveDown:)); 200 view.OnDoCommandBySelector(@selector(moveDown:));
200 EXPECT_EQ(1, model->up_or_down_count()); 201 EXPECT_EQ(1, model->up_or_down_count());
201 model->set_up_or_down_count(0); 202 model->set_up_or_down_count(0);
202 view.OnDoCommandBySelector(@selector(moveUp:)); 203 view.OnDoCommandBySelector(@selector(moveUp:));
203 EXPECT_EQ(-1, model->up_or_down_count()); 204 EXPECT_EQ(-1, model->up_or_down_count());
204 } 205 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser_toolbar_model_delegate.h ('k') | chrome/browser/ui/toolbar/chrome_toolbar_model_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698