Index: chrome/browser/autocomplete/search_provider_unittest.cc |
diff --git a/chrome/browser/autocomplete/search_provider_unittest.cc b/chrome/browser/autocomplete/search_provider_unittest.cc |
index 7f096da805225ebda9993f9d7bd90071777dd77d..1a93cc4a5152aad1b0a09b9111eb928e1352f3d9 100644 |
--- a/chrome/browser/autocomplete/search_provider_unittest.cc |
+++ b/chrome/browser/autocomplete/search_provider_unittest.cc |
@@ -8,6 +8,7 @@ |
#include "base/command_line.h" |
#include "base/metrics/field_trial.h" |
+#include "base/metrics/user_metrics.h" |
#include "base/prefs/pref_service.h" |
#include "base/run_loop.h" |
#include "base/strings/string16.h" |
@@ -65,37 +66,7 @@ ACMatches::const_iterator FindDefaultMatch(const ACMatches& matches) { |
return it; |
} |
-class SuggestionDeletionHandler; |
-class SearchProviderForTest : public SearchProvider { |
- public: |
- SearchProviderForTest(AutocompleteProviderListener* listener, |
- TemplateURLService* template_url_service, |
- Profile* profile); |
- bool is_success() { return is_success_; }; |
- |
- protected: |
- virtual ~SearchProviderForTest(); |
- |
- private: |
- virtual void RecordDeletionResult(bool success) OVERRIDE; |
- bool is_success_; |
- DISALLOW_COPY_AND_ASSIGN(SearchProviderForTest); |
-}; |
- |
-SearchProviderForTest::SearchProviderForTest( |
- AutocompleteProviderListener* listener, |
- TemplateURLService* template_url_service, |
- Profile* profile) |
- : SearchProvider(listener, template_url_service, profile), |
- is_success_(false) { |
-} |
- |
-SearchProviderForTest::~SearchProviderForTest() { |
-} |
- |
-void SearchProviderForTest::RecordDeletionResult(bool success) { |
- is_success_ = success; |
-} |
+void CopyString(std::string* out, const std::string& in) { *out = in; } |
} // namespace |
@@ -231,7 +202,10 @@ class SearchProviderTest : public testing::Test, |
TestingProfile profile_; |
// The provider. |
- scoped_refptr<SearchProviderForTest> provider_; |
+ scoped_refptr<SearchProvider> provider_; |
+ |
+ // The last action recorded with base::RecordAction(). |
+ std::string last_user_metrics_action_; |
// If non-NULL, OnProviderUpdate quits the current |run_loop_|. |
base::RunLoop* run_loop_; |
@@ -289,8 +263,10 @@ void SearchProviderTest::SetUp() { |
// requests to ensure the InMemoryDatabase is the state we expect it. |
profile_.BlockUntilHistoryProcessesPendingRequests(); |
- provider_ = new SearchProviderForTest(this, turl_model, &profile_); |
+ provider_ = new SearchProvider(this, turl_model, &profile_); |
provider_->kMinimumTimeBetweenSuggestQueriesMs = 0; |
+ |
+ base::AddActionCallback(base::Bind(&CopyString, &last_user_metrics_action_)); |
} |
void SearchProviderTest::TearDown() { |
@@ -3078,7 +3054,7 @@ TEST_F(SearchProviderTest, TestDeleteMatch) { |
fetcher->set_response_code(200); |
fetcher->delegate()->OnURLFetchComplete(fetcher); |
EXPECT_TRUE(provider_->deletion_handlers_.empty()); |
- EXPECT_TRUE(provider_->is_success()); |
+ EXPECT_EQ("Omnibox.ServerSuggestDelete.Success", last_user_metrics_action_); |
// Test a failing deletion request. |
provider_->matches_.push_back(match); |
@@ -3091,7 +3067,7 @@ TEST_F(SearchProviderTest, TestDeleteMatch) { |
fetcher->set_response_code(500); |
fetcher->delegate()->OnURLFetchComplete(fetcher); |
EXPECT_TRUE(provider_->deletion_handlers_.empty()); |
- EXPECT_FALSE(provider_->is_success()); |
+ EXPECT_EQ("Omnibox.ServerSuggestDelete.Failure", last_user_metrics_action_); |
} |
TEST_F(SearchProviderTest, TestDeleteHistoryQueryMatch) { |