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

Side by Side Diff: chrome/browser/push_messaging/background_budget_service_unittest.cc

Issue 1889513004: Make BackgroundBudgetService a KeyedService (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ses_integration
Patch Set: Apply diffs to master branch to remove SES dependency Created 4 years, 8 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 <stdint.h> 5 #include <stdint.h>
6 #include <string> 6 #include <string>
7 7
8 #include "chrome/browser/push_messaging/background_budget_service.h" 8 #include "chrome/browser/push_messaging/background_budget_service.h"
9 #include "chrome/browser/push_messaging/background_budget_service_factory.h"
9 #include "chrome/test/base/testing_profile.h" 10 #include "chrome/test/base/testing_profile.h"
10 #include "content/public/test/test_browser_thread_bundle.h" 11 #include "content/public/test/test_browser_thread_bundle.h"
11 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
12 13
13 namespace { 14 namespace {
14 15
15 const char kTestOrigin[] = "https://example.com"; 16 const char kTestOrigin[] = "https://example.com";
16 const char kTestData[] = "1111101111"; 17 const char kTestData[] = "1111101111";
17 18
18 } // namespace 19 } // namespace
19 20
20 class BackgroundBudgetServiceTest : public testing::Test { 21 class BackgroundBudgetServiceTest : public testing::Test {
21 public: 22 public:
22 BackgroundBudgetServiceTest() {} 23 BackgroundBudgetServiceTest() {}
23 ~BackgroundBudgetServiceTest() override {} 24 ~BackgroundBudgetServiceTest() override {}
24 25
25 TestingProfile* profile() { return &profile_; } 26 BackgroundBudgetService* service() {
27 return BackgroundBudgetServiceFactory::GetForProfile(&profile_);
28 }
26 29
27 private: 30 private:
28 content::TestBrowserThreadBundle thread_bundle_; 31 content::TestBrowserThreadBundle thread_bundle_;
29 TestingProfile profile_; 32 TestingProfile profile_;
30 }; 33 };
31 34
32 TEST_F(BackgroundBudgetServiceTest, GetBudgetFailure) { 35 TEST_F(BackgroundBudgetServiceTest, GetBudgetFailure) {
33 const GURL origin(kTestOrigin); 36 const GURL origin(kTestOrigin);
34 37
35 std::string budget_string = 38 std::string budget_string = service()->GetBudget(origin);
36 BackgroundBudgetService::GetBudget(profile(), origin);
37 39
38 EXPECT_EQ(std::string(), budget_string); 40 EXPECT_EQ(std::string(), budget_string);
39 } 41 }
40 42
41 TEST_F(BackgroundBudgetServiceTest, GetBudgetSuccess) { 43 TEST_F(BackgroundBudgetServiceTest, GetBudgetSuccess) {
42 const GURL origin(kTestOrigin); 44 const GURL origin(kTestOrigin);
43 45
44 BackgroundBudgetService::StoreBudget(profile(), origin, kTestData); 46 service()->StoreBudget(origin, kTestData);
45 47
46 std::string budget_string = 48 std::string budget_string = service()->GetBudget(origin);
47 BackgroundBudgetService::GetBudget(profile(), origin);
48 49
49 EXPECT_EQ(kTestData, budget_string); 50 EXPECT_EQ(kTestData, budget_string);
50 } 51 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698