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

Unified Diff: chrome/browser/metrics/variations_service_unittest.cc

Issue 10790116: Have the VariationsService attempt to fetch the seed when an update is ready. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Unit test Created 8 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/metrics/variations_service_unittest.cc
diff --git a/chrome/browser/metrics/variations_service_unittest.cc b/chrome/browser/metrics/variations_service_unittest.cc
index d51149f1a1b93396d8efd06b83e836874fc7388d..33079715f4442282a1f060207d51dad7e8dab4d0 100644
--- a/chrome/browser/metrics/variations_service_unittest.cc
+++ b/chrome/browser/metrics/variations_service_unittest.cc
@@ -6,15 +6,42 @@
#include "base/string_split.h"
#include "chrome/browser/metrics/proto/study.pb.h"
#include "chrome/browser/metrics/variations_service.h"
+#include "chrome/browser/upgrade_detector.h"
#include "chrome/common/chrome_version_info.h"
#include "chrome/common/pref_names.h"
+#include "chrome/common/chrome_notification_types.h"
#include "chrome/test/base/testing_pref_service.h"
+#include "content/public/browser/notification_service.h"
+#include "content/public/test/test_browser_thread.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace chrome_variations {
namespace {
+class TestVariationsService : public VariationsService {
Alexei Svitkine (slow) 2012/07/23 20:26:05 Add a short comment.
SteveT 2012/07/24 14:42:58 Done.
+ public:
+ TestVariationsService() {}
+ virtual ~TestVariationsService() {}
Alexei Svitkine (slow) 2012/07/23 20:26:05 Nit: Blank line after this.
SteveT 2012/07/24 14:42:58 Done.
+ bool fetch_attempted() { return fetch_attempted_; }
+
+ void SimulateUpgradeAvailable() {
Alexei Svitkine (slow) 2012/07/23 20:26:05 Add a comment.
SteveT 2012/07/24 14:42:58 Done.
+ Observe(chrome::NOTIFICATION_UPGRADE_RECOMMENDED,
+ content::Source<UpgradeDetector>(NULL),
+ content::NotificationService::NoDetails());
+ }
+
+ protected:
+ virtual void FetchVariationsSeed();
+
+ private:
+ bool fetch_attempted_;
+};
Alexei Svitkine (slow) 2012/07/23 20:26:05 DISALLOW_COPY_AND_ASSIGN?
SteveT 2012/07/24 14:42:58 Done.
+
+void TestVariationsService::FetchVariationsSeed() {
+ fetch_attempted_ = true;
Alexei Svitkine (slow) 2012/07/23 20:26:05 Nit: Inline.
SteveT 2012/07/24 14:42:58 Done.
+}
+
// Converts |time| to Study proto format.
int64 TimeToProtoTime(const base::Time& time) {
return (time - base::Time::UnixEpoch()).InSeconds();
@@ -37,6 +64,18 @@ chrome_variations::TrialsSeed CreateTestSeed() {
} // namespace
+TEST(VariationsServiceTest, AttemptFetchOnAutoUpdate) {
+ // Simulate an auto-update and ensure that the VariationsService attempts
+ // to fetch the variations seed.
+ MessageLoopForUI message_loop;
+ content::TestBrowserThread ui_thread(content::BrowserThread::UI,
+ &message_loop);
+ TestVariationsService test_service;
+ ASSERT_FALSE(test_service.fetch_attempted());
+ test_service.SimulateUpgradeAvailable();
+ ASSERT_TRUE(test_service.fetch_attempted());
+}
+
TEST(VariationsServiceTest, CheckStudyChannel) {
const chrome::VersionInfo::Channel channels[] = {
chrome::VersionInfo::CHANNEL_CANARY,
« chrome/browser/metrics/variations_service.cc ('K') | « chrome/browser/metrics/variations_service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698