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 #include "base/utf_string_conversions.h" | 5 #include "base/utf_string_conversions.h" |
6 #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h" | 6 #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h" |
7 #include "chrome/browser/search_engines/template_url_service_factory.h" | 7 #include "chrome/browser/search_engines/template_url_service_factory.h" |
8 #include "chrome/browser/ui/omnibox/omnibox_edit_controller.h" | 8 #include "chrome/browser/ui/omnibox/omnibox_edit_controller.h" |
9 #include "chrome/browser/ui/omnibox/omnibox_edit_model.h" | 9 #include "chrome/browser/ui/omnibox/omnibox_edit_model.h" |
10 #include "chrome/browser/ui/omnibox/omnibox_view.h" | 10 #include "chrome/browser/ui/omnibox/omnibox_view.h" |
11 #include "chrome/test/base/testing_browser_process.h" | 11 #include "chrome/test/base/testing_browser_process.h" |
12 #include "chrome/test/base/testing_profile.h" | 12 #include "chrome/test/base/testing_profile.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
14 #include "third_party/skia/include/core/SkBitmap.h" | 14 #include "third_party/skia/include/core/SkBitmap.h" |
15 #include "ui/gfx/font.h" | 15 #include "ui/gfx/font.h" |
16 | 16 |
17 using content::WebContents; | 17 using content::WebContents; |
18 | 18 |
19 namespace { | 19 namespace { |
20 | 20 |
21 class TestingOmniboxView : public OmniboxView { | 21 class TestingOmniboxView : public OmniboxView { |
22 public: | 22 public: |
23 TestingOmniboxView() {} | 23 TestingOmniboxView() : OmniboxView(NULL, NULL, NULL, NULL) {} |
Peter Kasting
2012/07/26 03:59:17
Nit: Technically, we're not supposed to provide in
dominich
2012/07/26 22:33:24
I think for testing it's often ignored. Especially
| |
24 | 24 |
25 virtual OmniboxEditModel* model() OVERRIDE { return NULL; } | 25 virtual OmniboxEditModel* GetModel() OVERRIDE { return NULL; } |
Peter Kasting
2012/07/26 03:59:17
Nit: Given that this class already passes the supe
dominich
2012/07/26 22:33:24
Done.
| |
26 virtual const OmniboxEditModel* model() const OVERRIDE { return NULL; } | 26 virtual const OmniboxEditModel* GetModel() const OVERRIDE { return NULL; } |
27 virtual void SaveStateToTab(WebContents* tab) OVERRIDE {} | 27 virtual void SaveStateToTab(WebContents* tab) OVERRIDE {} |
28 virtual void Update(const WebContents* tab_for_state_restoring) OVERRIDE {} | 28 virtual void Update(const WebContents* tab_for_state_restoring) OVERRIDE {} |
29 virtual void OpenMatch(const AutocompleteMatch& match, | 29 virtual void OpenMatch(const AutocompleteMatch& match, |
30 WindowOpenDisposition disposition, | 30 WindowOpenDisposition disposition, |
31 const GURL& alternate_nav_url, | 31 const GURL& alternate_nav_url, |
32 size_t selected_line) OVERRIDE {} | 32 size_t selected_line) OVERRIDE {} |
33 virtual string16 GetText() const OVERRIDE { return string16(); } | 33 virtual string16 GetText() const OVERRIDE { return string16(); } |
34 virtual bool IsEditingOrEmpty() const OVERRIDE { return true; } | 34 virtual bool IsEditingOrEmpty() const OVERRIDE { return true; } |
35 virtual int GetIcon() const OVERRIDE { return 0; } | 35 virtual int GetIcon() const OVERRIDE { return 0; } |
36 virtual void SetUserText(const string16& text) OVERRIDE {} | |
37 virtual void SetUserText(const string16& text, | 36 virtual void SetUserText(const string16& text, |
38 const string16& display_text, | 37 const string16& display_text, |
39 bool update_popup) OVERRIDE {} | 38 bool update_popup) OVERRIDE {} |
40 virtual void SetWindowTextAndCaretPos(const string16& text, | 39 virtual void SetWindowTextAndCaretPos(const string16& text, |
41 size_t caret_pos, | 40 size_t caret_pos, |
42 bool update_popup, | 41 bool update_popup, |
43 bool notify_text_changed) OVERRIDE {} | 42 bool notify_text_changed) OVERRIDE {} |
44 virtual void SetForcedQuery() OVERRIDE {} | 43 virtual void SetForcedQuery() OVERRIDE {} |
45 virtual bool IsSelectAll() const OVERRIDE { return false; } | 44 virtual bool IsSelectAll() const OVERRIDE { return false; } |
46 virtual bool DeleteAtEndPressed() OVERRIDE { return false; } | 45 virtual bool DeleteAtEndPressed() OVERRIDE { return false; } |
(...skipping 11 matching lines...) Expand all Loading... | |
58 return false; | 57 return false; |
59 } | 58 } |
60 virtual void OnRevertTemporaryText() OVERRIDE {} | 59 virtual void OnRevertTemporaryText() OVERRIDE {} |
61 virtual void OnBeforePossibleChange() OVERRIDE {} | 60 virtual void OnBeforePossibleChange() OVERRIDE {} |
62 virtual bool OnAfterPossibleChange() OVERRIDE { return false; } | 61 virtual bool OnAfterPossibleChange() OVERRIDE { return false; } |
63 virtual gfx::NativeView GetNativeView() const OVERRIDE { return NULL; } | 62 virtual gfx::NativeView GetNativeView() const OVERRIDE { return NULL; } |
64 virtual gfx::NativeView GetRelativeWindowForPopup() const OVERRIDE { | 63 virtual gfx::NativeView GetRelativeWindowForPopup() const OVERRIDE { |
65 return NULL; | 64 return NULL; |
66 } | 65 } |
67 virtual CommandUpdater* GetCommandUpdater() OVERRIDE { return NULL; } | 66 virtual CommandUpdater* GetCommandUpdater() OVERRIDE { return NULL; } |
67 virtual const CommandUpdater* GetCommandUpdater() const OVERRIDE { | |
68 return NULL; | |
69 } | |
68 virtual void SetInstantSuggestion(const string16& input, | 70 virtual void SetInstantSuggestion(const string16& input, |
69 bool animate_to_complete) OVERRIDE {} | 71 bool animate_to_complete) OVERRIDE {} |
70 virtual string16 GetInstantSuggestion() const OVERRIDE { return string16(); } | 72 virtual string16 GetInstantSuggestion() const OVERRIDE { return string16(); } |
71 virtual int TextWidth() const OVERRIDE { return 0; } | 73 virtual int TextWidth() const OVERRIDE { return 0; } |
72 virtual bool IsImeComposing() const OVERRIDE { return false; } | 74 virtual bool IsImeComposing() const OVERRIDE { return false; } |
73 | 75 |
74 #if defined(TOOLKIT_VIEWS) | 76 #if defined(TOOLKIT_VIEWS) |
75 virtual int GetMaxEditWidth(int entry_width) const OVERRIDE { | 77 virtual int GetMaxEditWidth(int entry_width) const OVERRIDE { |
76 return entry_width; | 78 return entry_width; |
77 } | 79 } |
78 virtual views::View* AddToView(views::View* parent) OVERRIDE { return NULL; } | 80 virtual views::View* AddToView(views::View* parent) OVERRIDE { return NULL; } |
79 virtual int OnPerformDrop(const views::DropTargetEvent& event) OVERRIDE { | 81 virtual int OnPerformDrop(const views::DropTargetEvent& event) OVERRIDE { |
80 return 0; | 82 return 0; |
81 } | 83 } |
82 virtual gfx::Font GetFont() { return gfx::Font(); } | 84 virtual gfx::Font GetFont() { return gfx::Font(); } |
83 virtual int WidthOfTextAfterCursor() { return 0; } | 85 virtual int WidthOfTextAfterCursor() { return 0; } |
84 #endif | 86 #endif |
85 | 87 |
88 virtual int GetOmniboxTextLength() const OVERRIDE { return 0; } | |
89 virtual void EmphasizeURLComponents() OVERRIDE { } | |
90 | |
86 private: | 91 private: |
87 DISALLOW_COPY_AND_ASSIGN(TestingOmniboxView); | 92 DISALLOW_COPY_AND_ASSIGN(TestingOmniboxView); |
88 }; | 93 }; |
89 | 94 |
90 class TestingOmniboxEditController : public OmniboxEditController { | 95 class TestingOmniboxEditController : public OmniboxEditController { |
91 public: | 96 public: |
92 TestingOmniboxEditController() {} | 97 TestingOmniboxEditController() {} |
93 virtual void OnAutocompleteAccept(const GURL& url, | 98 virtual void OnAutocompleteAccept(const GURL& url, |
94 WindowOpenDisposition disposition, | 99 WindowOpenDisposition disposition, |
95 content::PageTransition transition, | 100 content::PageTransition transition, |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
178 GURL url; | 183 GURL url; |
179 bool write_url; | 184 bool write_url; |
180 model.AdjustTextForCopy(input[i].sel_start, input[i].is_all_selected, | 185 model.AdjustTextForCopy(input[i].sel_start, input[i].is_all_selected, |
181 &result, &url, &write_url); | 186 &result, &url, &write_url); |
182 EXPECT_EQ(ASCIIToUTF16(input[i].expected_output), result) << "@: " << i; | 187 EXPECT_EQ(ASCIIToUTF16(input[i].expected_output), result) << "@: " << i; |
183 EXPECT_EQ(input[i].write_url, write_url) << " @" << i; | 188 EXPECT_EQ(input[i].write_url, write_url) << " @" << i; |
184 if (write_url) | 189 if (write_url) |
185 EXPECT_EQ(input[i].expected_url, url.spec()) << " @" << i; | 190 EXPECT_EQ(input[i].expected_url, url.spec()) << " @" << i; |
186 } | 191 } |
187 } | 192 } |
OLD | NEW |