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

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: use testing macros for friendliness 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
« no previous file with comments | « no previous file | chrome/browser/ui/app_list/search/mixer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..f84c701167d45386c44dcee3ee01d167a62bbdb0 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,11 +50,33 @@ 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.
+ void Publish(const SortedResults& results,
Matt Giuca 2014/07/08 06:09:08 Please make this (and RemoveDuplicates) static. (T
calamity 2014/07/08 07:54:31 Done.
+ AppListModel::SearchResults* ui_results);
+
void FetchResults(const KnownResults& known_results);
+ // Removes duplicates from |results|.
+ void RemoveDuplicates(SortedResults* results);
+
AppListModel::SearchResults* ui_results_; // Not owned.
Groups groups_;
« no previous file with comments | « no previous file | chrome/browser/ui/app_list/search/mixer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698