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

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

Issue 1861683002: Background service worker push message processing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed RunLoop 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include <stdint.h>
6 #include <string>
7
8 #include "chrome/browser/push_messaging/background_budget_service.h"
9 #include "chrome/test/base/testing_profile.h"
10 #include "content/public/test/test_browser_thread_bundle.h"
11 #include "testing/gtest/include/gtest/gtest.h"
12
13 namespace {
Bernhard Bauer 2016/04/11 13:58:42 Just FTR: You don't need the anonymous namespace i
harkness 2016/04/12 08:43:35 Good to know, although if you don't mind, I'll lea
14
15 const char kTestOrigin[] = "https://example.com";
16 const char kTestData[] = "1111101111";
17
18 } // namespace
19
20 class BackgroundBudgetServiceTest : public ::testing::Test {
Bernhard Bauer 2016/04/11 13:58:42 The initial :: isn't necessary if you are not insi
harkness 2016/04/12 08:43:35 Done.
21 public:
22 BackgroundBudgetServiceTest() {}
23 ~BackgroundBudgetServiceTest() override {}
24
25 TestingProfile* profile() { return &profile_; }
26
27 private:
28 content::TestBrowserThreadBundle thread_bundle_;
29 TestingProfile profile_;
30 };
31
32 TEST_F(BackgroundBudgetServiceTest, GetBudgetFailure) {
33 const GURL origin(kTestOrigin);
34
35 std::string budget_string =
36 BackgroundBudgetService::GetBudget(profile(), GURL(kTestOrigin));
Bernhard Bauer 2016/04/11 13:58:42 That's what |origin| is for, no? :)
harkness 2016/04/12 08:43:35 good point!
37
38 EXPECT_TRUE(budget_string.empty());
Bernhard Bauer 2016/04/11 13:58:42 Nit: If you compare this to an empty string with E
harkness 2016/04/12 08:43:35 Done.
39 }
40
41 TEST_F(BackgroundBudgetServiceTest, GetBudgetSuccess) {
42 const GURL origin(kTestOrigin);
43
44 BackgroundBudgetService::StoreBudget(profile(), GURL(kTestOrigin), kTestData);
45
46 std::string budget_string =
47 BackgroundBudgetService::GetBudget(profile(), GURL(kTestOrigin));
48
49 EXPECT_EQ(budget_string, kTestData);
50 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698