diff options
Diffstat (limited to 'chrome/browser/autocomplete/autocomplete_edit_unittest.cc')
-rw-r--r-- | chrome/browser/autocomplete/autocomplete_edit_unittest.cc | 59 |
1 files changed, 30 insertions, 29 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_edit_unittest.cc b/chrome/browser/autocomplete/autocomplete_edit_unittest.cc index f599db3..7643936 100644 --- a/chrome/browser/autocomplete/autocomplete_edit_unittest.cc +++ b/chrome/browser/autocomplete/autocomplete_edit_unittest.cc @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "base/utf_string_conversions.h" #include "chrome/browser/autocomplete/autocomplete_edit.h" #include "chrome/browser/autocomplete/autocomplete_edit_view.h" #include "chrome/test/testing_profile.h" @@ -23,30 +24,30 @@ class TestingAutocompleteEditView : public AutocompleteEditView { PageTransition::Type transition, const GURL& alternate_nav_url, size_t selected_line, - const std::wstring& keyword) {} - virtual std::wstring GetText() const { return std::wstring(); } + const string16& keyword) {} + virtual string16 GetText() const { return string16(); } virtual bool IsEditingOrEmpty() const { return true; } virtual int GetIcon() const { return 0; } - virtual void SetUserText(const std::wstring& text) {} - virtual void SetUserText(const std::wstring& text, - const std::wstring& display_text, + virtual void SetUserText(const string16& text) {} + virtual void SetUserText(const string16& text, + const string16& display_text, bool update_popup) {} - virtual void SetWindowTextAndCaretPos(const std::wstring& text, + virtual void SetWindowTextAndCaretPos(const string16& text, size_t caret_pos) {} virtual void SetForcedQuery() {} virtual bool IsSelectAll() { return false; } virtual bool DeleteAtEndPressed() { return false; } - virtual void GetSelectionBounds(std::wstring::size_type* start, - std::wstring::size_type* end) {} + virtual void GetSelectionBounds(string16::size_type* start, + string16::size_type* end) {} virtual void SelectAll(bool reversed) {} virtual void RevertAll() {} virtual void UpdatePopup() {} virtual void ClosePopup() {} virtual void SetFocus() {} - virtual void OnTemporaryTextMaybeChanged(const std::wstring& display_text, + virtual void OnTemporaryTextMaybeChanged(const string16& display_text, bool save_original_selection) {} virtual bool OnInlineAutocompleteTextMaybeChanged( - const std::wstring& display_text, size_t user_text_length) { + const string16& display_text, size_t user_text_length) { return false; } virtual void OnRevertTemporaryText() {} @@ -61,8 +62,8 @@ class TestingAutocompleteEditView : public AutocompleteEditView { #if defined(TOOLKIT_VIEWS) virtual views::View* AddToView(views::View* parent) { return NULL; } virtual bool CommitInstantSuggestion( - const std::wstring& typed_text, - const std::wstring& suggested_text) { return false;} + const string16& typed_text, + const string16& suggested_text) { return false; } #endif private: @@ -75,7 +76,7 @@ class TestingAutocompleteEditController : public AutocompleteEditController { virtual void OnAutocompleteWillClosePopup() {} virtual void OnAutocompleteLosingFocus(gfx::NativeView view_gaining_focus) {} virtual void OnAutocompleteWillAccept() {} - virtual bool OnCommitSuggestedText(const std::wstring& typed_text) { + virtual bool OnCommitSuggestedText(const string16& typed_text) { return false; } virtual bool AcceptCurrentInstantPreview() { @@ -92,7 +93,7 @@ class TestingAutocompleteEditController : public AutocompleteEditController { virtual void OnKillFocus() {} virtual void OnSetFocus() {} virtual SkBitmap GetFavIcon() const { return SkBitmap(); } - virtual std::wstring GetTitle() const { return std::wstring(); } + virtual string16 GetTitle() const { return string16(); } private: DISALLOW_COPY_AND_ASSIGN(TestingAutocompleteEditController); @@ -105,41 +106,41 @@ typedef testing::Test AutocompleteEditTest; // Tests various permutations of AutocompleteModel::AdjustTextForCopy. TEST(AutocompleteEditTest, AdjustTextForCopy) { struct Data { - const wchar_t* perm_text; + const char* perm_text; const int sel_start; const bool is_all_selected; - const wchar_t* input; - const wchar_t* expected_output; + const char* input; + const char* expected_output; const bool write_url; const char* expected_url; } input[] = { // Test that http:// is inserted if all text is selected. - { L"a.b/c", 0, true, L"a.b/c", L"http://a.b/c", true, "http://a.b/c" }, + { "a.b/c", 0, true, "a.b/c", "http://a.b/c", true, "http://a.b/c" }, // Test that http:// is inserted if the host is selected. - { L"a.b/c", 0, false, L"a.b/", L"http://a.b/", true, "http://a.b/" }, + { "a.b/c", 0, false, "a.b/", "http://a.b/", true, "http://a.b/" }, // Tests that http:// is inserted if the path is modified. - { L"a.b/c", 0, false, L"a.b/d", L"http://a.b/d", true, "http://a.b/d" }, + { "a.b/c", 0, false, "a.b/d", "http://a.b/d", true, "http://a.b/d" }, // Tests that http:// isn't inserted if the host is modified. - { L"a.b/c", 0, false, L"a.c/", L"a.c/", false, "" }, + { "a.b/c", 0, false, "a.c/", "a.c/", false, "" }, // Tests that http:// isn't inserted if the start of the selection is 1. - { L"a.b/c", 1, false, L"a.b/", L"a.b/", false, "" }, + { "a.b/c", 1, false, "a.b/", "a.b/", false, "" }, // Tests that http:// isn't inserted if a portion of the host is selected. - { L"a.com/", 0, false, L"a.co", L"a.co", false, "" }, + { "a.com/", 0, false, "a.co", "a.co", false, "" }, // Tests that http:// isn't inserted for an https url after the user nukes // https. - { L"https://a.com/", 0, false, L"a.com/", L"a.com/", false, "" }, + { "https://a.com/", 0, false, "a.com/", "a.com/", false, "" }, // Tests that http:// isn't inserted if the user adds to the host. - { L"a.b/", 0, false, L"a.bc/", L"a.bc/", false, "" }, + { "a.b/", 0, false, "a.bc/", "a.bc/", false, "" }, // Tests that we don't get double http if the user manually inserts http. - { L"a.b/", 0, false, L"http://a.b/", L"http://a.b/", true, "http://a.b/" }, + { "a.b/", 0, false, "http://a.b/", "http://a.b/", true, "http://a.b/" }, }; TestingAutocompleteEditView view; TestingAutocompleteEditController controller; @@ -147,14 +148,14 @@ TEST(AutocompleteEditTest, AdjustTextForCopy) { AutocompleteEditModel model(&view, &controller, &profile); for (size_t i = 0; i < ARRAYSIZE_UNSAFE(input); ++i) { - model.UpdatePermanentText(input[i].perm_text); + model.UpdatePermanentText(ASCIIToUTF16(input[i].perm_text)); - std::wstring result(input[i].input); + string16 result = ASCIIToUTF16(input[i].input); GURL url; bool write_url; model.AdjustTextForCopy(input[i].sel_start, input[i].is_all_selected, &result, &url, &write_url); - EXPECT_EQ(input[i].expected_output, result) << "@: " << i; + EXPECT_EQ(ASCIIToUTF16(input[i].expected_output), result) << "@: " << i; EXPECT_EQ(input[i].write_url, write_url) << " @" << i; if (write_url) EXPECT_EQ(input[i].expected_url, url.spec()) << " @" << i; |