Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(158)

Unified Diff: chrome/browser/ui/app_list/search/mixer.h

Issue 372843003: Add unit test for Mixer::Publish. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add instance ids to TestSearchResult Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/app_list/search/mixer.h
diff --git a/chrome/browser/ui/app_list/search/mixer.h b/chrome/browser/ui/app_list/search/mixer.h
index b195d6371a842ff4ba2d554ee6a3f19aa4713845..b7e16415f45c6856b5a9ef028f6ef786e72d4c3e 100644
--- a/chrome/browser/ui/app_list/search/mixer.h
+++ b/chrome/browser/ui/app_list/search/mixer.h
@@ -6,12 +6,18 @@
#define CHROME_BROWSER_UI_APP_LIST_SEARCH_MIXER_H_
#include "base/basictypes.h"
+#include "base/gtest_prod_util.h"
#include "base/memory/scoped_vector.h"
#include "chrome/browser/ui/app_list/search/history_types.h"
#include "ui/app_list/app_list_model.h"
namespace app_list {
+namespace test {
+FORWARD_DECLARE_TEST(MixerTest, Publish);
+}
+
+class ChromeSearchResult;
class SearchProvider;
// Mixer collects results from providers, sorts them and publishes them to the
@@ -44,9 +50,31 @@ class Mixer {
void MixAndPublish(const KnownResults& known_results);
private:
+ FRIEND_TEST_ALL_PREFIXES(test::MixerTest, Publish);
+
+ // Used for sorting and mixing results.
+ struct SortData {
+ SortData();
+ SortData(ChromeSearchResult* result, double score);
+
+ bool operator<(const SortData& other) const;
+
+ ChromeSearchResult* result; // Not owned.
+ double score;
+ };
+ typedef std::vector<Mixer::SortData> SortedResults;
+
class Group;
typedef ScopedVector<Group> Groups;
+ // Publishes the given |results| to |ui_results|. Reuse existing ones to avoid
+ // flickering.
+ static void Publish(const SortedResults& results,
+ AppListModel::SearchResults* ui_results);
+
+ // Removes duplicates from |results|.
+ static void RemoveDuplicates(SortedResults* results);
+
void FetchResults(const KnownResults& known_results);
AppListModel::SearchResults* ui_results_; // Not owned.
« no previous file with comments | « no previous file | chrome/browser/ui/app_list/search/mixer.cc » ('j') | chrome/browser/ui/app_list/search/mixer_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698