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) {} |
24 | 24 |
25 virtual OmniboxEditModel* model() OVERRIDE { return NULL; } | |
26 virtual const OmniboxEditModel* model() const OVERRIDE { return NULL; } | |
27 virtual void SaveStateToTab(WebContents* tab) OVERRIDE {} | 25 virtual void SaveStateToTab(WebContents* tab) OVERRIDE {} |
28 virtual void Update(const WebContents* tab_for_state_restoring) OVERRIDE {} | 26 virtual void Update(const WebContents* tab_for_state_restoring) OVERRIDE {} |
29 virtual void OpenMatch(const AutocompleteMatch& match, | 27 virtual void OpenMatch(const AutocompleteMatch& match, |
30 WindowOpenDisposition disposition, | 28 WindowOpenDisposition disposition, |
31 const GURL& alternate_nav_url, | 29 const GURL& alternate_nav_url, |
32 size_t selected_line) OVERRIDE {} | 30 size_t selected_line) OVERRIDE {} |
33 virtual string16 GetText() const OVERRIDE { return string16(); } | 31 virtual string16 GetText() const OVERRIDE { return string16(); } |
34 virtual bool IsEditingOrEmpty() const OVERRIDE { return true; } | 32 virtual bool IsEditingOrEmpty() const OVERRIDE { return true; } |
35 virtual int GetIcon() const OVERRIDE { return 0; } | 33 virtual int GetIcon() const OVERRIDE { return 0; } |
36 virtual void SetUserText(const string16& text) OVERRIDE {} | |
37 virtual void SetUserText(const string16& text, | 34 virtual void SetUserText(const string16& text, |
38 const string16& display_text, | 35 const string16& display_text, |
39 bool update_popup) OVERRIDE {} | 36 bool update_popup) OVERRIDE {} |
40 virtual void SetWindowTextAndCaretPos(const string16& text, | 37 virtual void SetWindowTextAndCaretPos(const string16& text, |
41 size_t caret_pos, | 38 size_t caret_pos, |
42 bool update_popup, | 39 bool update_popup, |
43 bool notify_text_changed) OVERRIDE {} | 40 bool notify_text_changed) OVERRIDE {} |
44 virtual void SetForcedQuery() OVERRIDE {} | 41 virtual void SetForcedQuery() OVERRIDE {} |
45 virtual bool IsSelectAll() const OVERRIDE { return false; } | 42 virtual bool IsSelectAll() const OVERRIDE { return false; } |
46 virtual bool DeleteAtEndPressed() OVERRIDE { return false; } | 43 virtual bool DeleteAtEndPressed() OVERRIDE { return false; } |
(...skipping 10 matching lines...) Expand all Loading... |
57 const string16& display_text, size_t user_text_length) OVERRIDE { | 54 const string16& display_text, size_t user_text_length) OVERRIDE { |
58 return false; | 55 return false; |
59 } | 56 } |
60 virtual void OnRevertTemporaryText() OVERRIDE {} | 57 virtual void OnRevertTemporaryText() OVERRIDE {} |
61 virtual void OnBeforePossibleChange() OVERRIDE {} | 58 virtual void OnBeforePossibleChange() OVERRIDE {} |
62 virtual bool OnAfterPossibleChange() OVERRIDE { return false; } | 59 virtual bool OnAfterPossibleChange() OVERRIDE { return false; } |
63 virtual gfx::NativeView GetNativeView() const OVERRIDE { return NULL; } | 60 virtual gfx::NativeView GetNativeView() const OVERRIDE { return NULL; } |
64 virtual gfx::NativeView GetRelativeWindowForPopup() const OVERRIDE { | 61 virtual gfx::NativeView GetRelativeWindowForPopup() const OVERRIDE { |
65 return NULL; | 62 return NULL; |
66 } | 63 } |
67 virtual CommandUpdater* GetCommandUpdater() OVERRIDE { return NULL; } | |
68 virtual void SetInstantSuggestion(const string16& input, | 64 virtual void SetInstantSuggestion(const string16& input, |
69 bool animate_to_complete) OVERRIDE {} | 65 bool animate_to_complete) OVERRIDE {} |
70 virtual string16 GetInstantSuggestion() const OVERRIDE { return string16(); } | 66 virtual string16 GetInstantSuggestion() const OVERRIDE { return string16(); } |
71 virtual int TextWidth() const OVERRIDE { return 0; } | 67 virtual int TextWidth() const OVERRIDE { return 0; } |
72 virtual bool IsImeComposing() const OVERRIDE { return false; } | 68 virtual bool IsImeComposing() const OVERRIDE { return false; } |
73 | 69 |
74 #if defined(TOOLKIT_VIEWS) | 70 #if defined(TOOLKIT_VIEWS) |
75 virtual int GetMaxEditWidth(int entry_width) const OVERRIDE { | 71 virtual int GetMaxEditWidth(int entry_width) const OVERRIDE { |
76 return entry_width; | 72 return entry_width; |
77 } | 73 } |
78 virtual views::View* AddToView(views::View* parent) OVERRIDE { return NULL; } | 74 virtual views::View* AddToView(views::View* parent) OVERRIDE { return NULL; } |
79 virtual int OnPerformDrop(const views::DropTargetEvent& event) OVERRIDE { | 75 virtual int OnPerformDrop(const views::DropTargetEvent& event) OVERRIDE { |
80 return 0; | 76 return 0; |
81 } | 77 } |
82 virtual gfx::Font GetFont() { return gfx::Font(); } | 78 virtual gfx::Font GetFont() { return gfx::Font(); } |
83 virtual int WidthOfTextAfterCursor() { return 0; } | 79 virtual int WidthOfTextAfterCursor() { return 0; } |
84 #endif | 80 #endif |
85 | 81 |
| 82 virtual int GetOmniboxTextLength() const OVERRIDE { return 0; } |
| 83 virtual void EmphasizeURLComponents() OVERRIDE { } |
| 84 |
86 private: | 85 private: |
87 DISALLOW_COPY_AND_ASSIGN(TestingOmniboxView); | 86 DISALLOW_COPY_AND_ASSIGN(TestingOmniboxView); |
88 }; | 87 }; |
89 | 88 |
90 class TestingOmniboxEditController : public OmniboxEditController { | 89 class TestingOmniboxEditController : public OmniboxEditController { |
91 public: | 90 public: |
92 TestingOmniboxEditController() {} | 91 TestingOmniboxEditController() {} |
93 virtual void OnAutocompleteAccept(const GURL& url, | 92 virtual void OnAutocompleteAccept(const GURL& url, |
94 WindowOpenDisposition disposition, | 93 WindowOpenDisposition disposition, |
95 content::PageTransition transition, | 94 content::PageTransition transition, |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 GURL url; | 177 GURL url; |
179 bool write_url; | 178 bool write_url; |
180 model.AdjustTextForCopy(input[i].sel_start, input[i].is_all_selected, | 179 model.AdjustTextForCopy(input[i].sel_start, input[i].is_all_selected, |
181 &result, &url, &write_url); | 180 &result, &url, &write_url); |
182 EXPECT_EQ(ASCIIToUTF16(input[i].expected_output), result) << "@: " << i; | 181 EXPECT_EQ(ASCIIToUTF16(input[i].expected_output), result) << "@: " << i; |
183 EXPECT_EQ(input[i].write_url, write_url) << " @" << i; | 182 EXPECT_EQ(input[i].write_url, write_url) << " @" << i; |
184 if (write_url) | 183 if (write_url) |
185 EXPECT_EQ(input[i].expected_url, url.spec()) << " @" << i; | 184 EXPECT_EQ(input[i].expected_url, url.spec()) << " @" << i; |
186 } | 185 } |
187 } | 186 } |
OLD | NEW |