Chromium Code Reviews| Index: chrome/browser/ui/app_list/search/app_search_provider_unittest.cc |
| diff --git a/chrome/browser/ui/app_list/search/app_search_provider_unittest.cc b/chrome/browser/ui/app_list/search/app_search_provider_unittest.cc |
| index 451eb5b7d669516bc4ae1676e49b6443dd25c58b..70e1a90b757ed8b0da42f66cc08369063b51b329 100644 |
| --- a/chrome/browser/ui/app_list/search/app_search_provider_unittest.cc |
| +++ b/chrome/browser/ui/app_list/search/app_search_provider_unittest.cc |
| @@ -14,6 +14,7 @@ |
| #include "chrome/browser/ui/app_list/search/chrome_search_result.h" |
| #include "chrome/common/chrome_constants.h" |
| #include "chrome/test/base/testing_profile.h" |
| +#include "extensions/browser/extension_prefs.h" |
| #include "extensions/common/extension_set.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| @@ -32,10 +33,18 @@ class AppSearchProviderTest : public AppListTestBase { |
| app_search_.reset(new AppSearchProvider(profile_.get(), NULL)); |
| } |
| + std::string RunFetchRecommendations() { |
| + app_search_->FetchRecommendations(); |
| + return GetResultsString(); |
| + } |
| + |
| std::string RunQuery(const std::string& query) { |
| app_search_->Start(base::UTF8ToUTF16(query)); |
| - app_search_->Stop(); |
| + return GetResultsString(); |
| + } |
| + private: |
| + std::string GetResultsString() { |
| std::string result_str; |
| const SearchProvider::Results& results = app_search_->results(); |
| for (size_t i = 0; i < results.size(); ++i) { |
| @@ -47,7 +56,6 @@ class AppSearchProviderTest : public AppListTestBase { |
| return result_str; |
| } |
| - private: |
| scoped_ptr<AppSearchProvider> app_search_; |
| DISALLOW_COPY_AND_ASSIGN(AppSearchProviderTest); |
| @@ -92,5 +100,21 @@ TEST_F(AppSearchProviderTest, Uninstall) { |
| base::RunLoop().RunUntilIdle(); |
| } |
| +TEST_F(AppSearchProviderTest, FetchRecommendations) { |
| + extensions::ExtensionPrefs* prefs = |
| + extensions::ExtensionPrefs::Get(profile_.get()); |
| + prefs->SetLastLaunchTime(kHostedAppId, base::Time::FromInternalValue(20)); |
|
Matt Giuca
2014/07/22 04:31:07
This is sort of funny in terms of nondeterminism.
calamity
2014/07/22 07:24:04
Done.
|
| + prefs->SetLastLaunchTime(kPackagedApp1Id, base::Time::FromInternalValue(10)); |
| + prefs->SetLastLaunchTime(kPackagedApp2Id, base::Time::FromInternalValue(0)); |
| + EXPECT_EQ("Hosted App,Packaged App 1,Packaged App 2", |
| + RunFetchRecommendations()); |
| + |
| + prefs->SetLastLaunchTime(kHostedAppId, base::Time::FromInternalValue(0)); |
| + prefs->SetLastLaunchTime(kPackagedApp1Id, base::Time::FromInternalValue(10)); |
| + prefs->SetLastLaunchTime(kPackagedApp2Id, base::Time::FromInternalValue(20)); |
| + EXPECT_EQ("Packaged App 2,Packaged App 1,Hosted App", |
| + RunFetchRecommendations()); |
| +} |
| + |
| } // namespace test |
| } // namespace app_list |