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

Side by Side Diff: chrome/browser/web_resource/promo_resource_service_mobile_ntp_unittest.cc

Issue 1291543004: Inject JSON parsing in WebResource as a callback rather than inheritance (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@webResources1
Patch Set: Created 5 years, 4 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <vector> 5 #include <vector>
6 6
7 #include "base/json/json_reader.h" 7 #include "base/json/json_reader.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/prefs/testing_pref_service.h" 9 #include "base/prefs/testing_pref_service.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "base/time/time.h" 12 #include "base/time/time.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "chrome/browser/web_resource/notification_promo.h" 14 #include "chrome/browser/web_resource/notification_promo.h"
15 #include "chrome/browser/web_resource/notification_promo_mobile_ntp.h" 15 #include "chrome/browser/web_resource/notification_promo_mobile_ntp.h"
16 #include "chrome/browser/web_resource/promo_resource_service.h" 16 #include "chrome/browser/web_resource/promo_resource_service.h"
17 #include "components/version_info/version_info.h" 17 #include "components/version_info/version_info.h"
18 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
19 19
20 namespace { 20 namespace {
21 version_info::Channel kChannel = version_info::Channel::UNKNOWN; 21 version_info::Channel kChannel = version_info::Channel::UNKNOWN;
22 } 22 }
23 23
24 class PromoResourceServiceMobileNtpTest : public testing::Test { 24 class PromoResourceServiceMobileNtpTest : public testing::Test {
25 public: 25 public:
26 PromoResourceServiceMobileNtpTest() { 26 PromoResourceServiceMobileNtpTest() {
27 NotificationPromo::RegisterPrefs(local_state_.registry()); 27 NotificationPromo::RegisterPrefs(local_state_.registry());
28 promo_resource_service_.reset( 28 promo_resource_service_.reset(new PromoResourceService(
29 new PromoResourceService(&local_state_, kChannel)); 29 &local_state_, kChannel, "en", nullptr, nullptr,
30 web_resource::WebResourceService::ParseJSONCallback()));
30 } 31 }
31 32
32 protected: 33 protected:
33 TestingPrefServiceSimple local_state_; 34 TestingPrefServiceSimple local_state_;
34 // |promo_resource_service_| must be created after |local_state_|. 35 // |promo_resource_service_| must be created after |local_state_|.
35 scoped_ptr<PromoResourceService> promo_resource_service_; 36 scoped_ptr<PromoResourceService> promo_resource_service_;
36 base::MessageLoop loop_; 37 base::MessageLoop loop_;
37 }; 38 };
38 39
39 class NotificationPromoMobileNtpTest { 40 class NotificationPromoMobileNtpTest {
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 "It\'s simple. Go http://www.google.com/chrome/", 178 "It\'s simple. Go http://www.google.com/chrome/",
178 "ACTION_EMAIL", "This is the body.", "XXX value"); 179 "ACTION_EMAIL", "This is the body.", "XXX value");
179 180
180 promo_test.InitPromoFromJson(true); 181 promo_test.InitPromoFromJson(true);
181 182
182 // Second time should not trigger a notification. 183 // Second time should not trigger a notification.
183 promo_test.InitPromoFromJson(false); 184 promo_test.InitPromoFromJson(false);
184 185
185 promo_test.TestInitFromPrefs(); 186 promo_test.TestInitFromPrefs();
186 } 187 }
OLDNEW
« no previous file with comments | « chrome/browser/web_resource/promo_resource_service.cc ('k') | chrome/browser/web_resource/promo_resource_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698