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

Unified Diff: chrome/browser/web_resource/promo_resource_service_mobile_ntp_unittest.cc

Issue 11689004: Move PromoResourceService from Profile to BrowserProcessImpl/local_state(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: clang Created 7 years, 12 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/web_resource/promo_resource_service_mobile_ntp_unittest.cc
diff --git a/chrome/browser/web_resource/promo_resource_service_mobile_ntp_unittest.cc b/chrome/browser/web_resource/promo_resource_service_mobile_ntp_unittest.cc
index 89c7488f888d9722fbf53fcefce5b2005392232d..429daddd1213c048a9b9ffa5af4c804b8943918d 100644
--- a/chrome/browser/web_resource/promo_resource_service_mobile_ntp_unittest.cc
+++ b/chrome/browser/web_resource/promo_resource_service_mobile_ntp_unittest.cc
@@ -10,16 +10,12 @@
#include "base/time.h"
#include "base/utf_string_conversions.h"
#include "base/values.h"
-#include "chrome/browser/browser_process.h"
-#include "chrome/browser/prefs/browser_prefs.h"
-#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/web_resource/notification_promo.h"
#include "chrome/browser/web_resource/promo_resource_service.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_pref_service.h"
-#include "chrome/test/base/testing_profile.h"
#include "content/public/browser/notification_registrar.h"
#include "content/public/browser/notification_service.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -29,24 +25,21 @@
class PromoResourceServiceMobileNtpTest : public testing::Test {
public:
PromoResourceServiceMobileNtpTest()
- : local_state_(static_cast<TestingBrowserProcess*>(g_browser_process)),
- web_resource_service_(new PromoResourceService(&profile_)) {
+ : local_state_(TestingBrowserProcess::GetGlobal()) {
+ TestingBrowserProcess::GetGlobal()->SetLocalState(local_state_.Get());
Robert Sesek 2013/01/04 01:16:13 This needs to be NULLed in the dtor, at least I th
Dan Beam 2013/01/04 01:34:42 ScopedTestingLocalState both does that and DCHECKs
+ // |promo_resource_service_| must be created after local state is set.
+ promo_resource_service_ = new PromoResourceService;
}
protected:
- TestingProfile profile_;
ScopedTestingLocalState local_state_;
- scoped_refptr<PromoResourceService> web_resource_service_;
+ scoped_refptr<PromoResourceService> promo_resource_service_;
MessageLoop loop_;
};
class NotificationPromoMobileNtpTest {
public:
- explicit NotificationPromoMobileNtpTest(Profile* profile)
- : profile_(profile),
- prefs_(profile->GetPrefs()),
- mobile_promo_(profile),
- received_notification_(false) {
+ NotificationPromoMobileNtpTest() : received_notification_(false) {
}
void Init(const std::string& json,
@@ -72,8 +65,7 @@ class NotificationPromoMobileNtpTest {
}
void InitPromoFromJson(bool should_receive_notification) {
- const bool rv = mobile_promo_.InitFromJson(*test_json_);
- EXPECT_TRUE(rv);
+ EXPECT_TRUE(mobile_promo_.InitFromJson(*test_json_));
EXPECT_TRUE(mobile_promo_.valid());
EXPECT_EQ(should_receive_notification,
mobile_promo_.notification_promo().new_notification());
@@ -102,9 +94,8 @@ class NotificationPromoMobileNtpTest {
// Create a new NotificationPromo from prefs and compare to current
// notification.
void TestInitFromPrefs() {
- NotificationPromoMobileNtp prefs_mobile_promo(profile_);
- const bool rv = prefs_mobile_promo.InitFromPrefs();
- EXPECT_TRUE(rv);
+ NotificationPromoMobileNtp prefs_mobile_promo;
+ EXPECT_TRUE(prefs_mobile_promo.InitFromPrefs());
EXPECT_TRUE(prefs_mobile_promo.valid());
EXPECT_TRUE(mobile_promo_.valid());
@@ -131,8 +122,6 @@ class NotificationPromoMobileNtpTest {
}
private:
- Profile* profile_;
- PrefService* prefs_;
NotificationPromoMobileNtp mobile_promo_;
bool received_notification_;
scoped_ptr<DictionaryValue> test_json_;
@@ -144,11 +133,7 @@ class NotificationPromoMobileNtpTest {
};
TEST_F(PromoResourceServiceMobileNtpTest, NotificationPromoMobileNtpTest) {
- // Check that prefs are set correctly.
- PrefService* prefs = profile_.GetPrefs();
- ASSERT_TRUE(prefs);
-
- NotificationPromoMobileNtpTest promo_test(&profile_);
+ NotificationPromoMobileNtpTest promo_test;
// Set up start and end dates and promo line in a Dictionary as if parsed
// from the service.
@@ -175,7 +160,6 @@ TEST_F(PromoResourceServiceMobileNtpTest, NotificationPromoMobileNtpTest) {
" \"payload\":"
" {"
" \"payload_format_version\":3,"
- " \"gplus_required\":false,"
" \"promo_message_long\":"
" \"MOBILE_PROMO_CHROME_LONG_TEXT\","
" \"promo_message_short\":"

Powered by Google App Engine
This is Rietveld 408576698