| 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 "chrome/browser/autocomplete/contact_provider_chromeos.h" | 5 #include "chrome/browser/autocomplete/contact_provider_chromeos.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 profile_ = profile_manager_->CreateTestingProfile("test_profile"); | 60 profile_ = profile_manager_->CreateTestingProfile("test_profile"); |
| 61 contact_manager_.reset(new contacts::ContactManagerStub(profile_)); | 61 contact_manager_.reset(new contacts::ContactManagerStub(profile_)); |
| 62 contact_provider_ = | 62 contact_provider_ = |
| 63 new ContactProvider(NULL, profile_, contact_manager_->GetWeakPtr()); | 63 new ContactProvider(NULL, profile_, contact_manager_->GetWeakPtr()); |
| 64 } | 64 } |
| 65 | 65 |
| 66 // Starts a (synchronous) query for |utf8_text| in |contact_provider_|. | 66 // Starts a (synchronous) query for |utf8_text| in |contact_provider_|. |
| 67 void StartQuery(const std::string& utf8_text) { | 67 void StartQuery(const std::string& utf8_text) { |
| 68 contact_provider_->Start( | 68 contact_provider_->Start( |
| 69 AutocompleteInput(UTF8ToUTF16(utf8_text), | 69 AutocompleteInput(UTF8ToUTF16(utf8_text), |
| 70 string16(), // desired_tld | 70 string16::npos, // cursor_position |
| 71 false, // prevent_inline_autocomplete | 71 string16(), // desired_tld |
| 72 false, // prefer_keyword | 72 false, // prevent_inline_autocomplete |
| 73 false, // allow_exact_keyword_match | 73 false, // prefer_keyword |
| 74 false, // allow_exact_keyword_match |
| 74 AutocompleteInput::ALL_MATCHES), | 75 AutocompleteInput::ALL_MATCHES), |
| 75 false); // minimal_changes | 76 false); // minimal_changes |
| 76 } | 77 } |
| 77 | 78 |
| 78 // Returns the contact ID in |match|'s additional info, or an empty string if | 79 // Returns the contact ID in |match|'s additional info, or an empty string if |
| 79 // no ID is present. | 80 // no ID is present. |
| 80 std::string GetContactIdFromMatch(const AutocompleteMatch& match) { | 81 std::string GetContactIdFromMatch(const AutocompleteMatch& match) { |
| 81 AutocompleteMatch::AdditionalInfo::const_iterator it = | 82 AutocompleteMatch::AdditionalInfo::const_iterator it = |
| 82 match.additional_info.find(ContactProvider::kMatchContactIdKey); | 83 match.additional_info.find(ContactProvider::kMatchContactIdKey); |
| 83 return it != match.additional_info.end() ? it->second : std::string(); | 84 return it != match.additional_info.end() ? it->second : std::string(); |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 EXPECT_EQ(exp_contact.contact_id(), match_id) | 272 EXPECT_EQ(exp_contact.contact_id(), match_id) |
| 272 << "Expected contact ID " << exp_contact.contact_id() | 273 << "Expected contact ID " << exp_contact.contact_id() |
| 273 << " for match " << i << " but got " << match_id << " instead"; | 274 << " for match " << i << " but got " << match_id << " instead"; |
| 274 if (i > 0) { | 275 if (i > 0) { |
| 275 EXPECT_LE(matches[i].relevance, previous_relevance) | 276 EXPECT_LE(matches[i].relevance, previous_relevance) |
| 276 << "Match " << i << " has greater relevance than previous match"; | 277 << "Match " << i << " has greater relevance than previous match"; |
| 277 } | 278 } |
| 278 previous_relevance = matches[i].relevance; | 279 previous_relevance = matches[i].relevance; |
| 279 } | 280 } |
| 280 } | 281 } |
| OLD | NEW |