Chromium Code Reviews| Index: chrome/browser/push_messaging/background_budget_service_unittest.cc |
| diff --git a/chrome/browser/push_messaging/background_budget_service_unittest.cc b/chrome/browser/push_messaging/background_budget_service_unittest.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..5bb5da62dab0dbdb4067ed1a28817cb2beeb11ac |
| --- /dev/null |
| +++ b/chrome/browser/push_messaging/background_budget_service_unittest.cc |
| @@ -0,0 +1,50 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include <stdint.h> |
| +#include <string> |
| + |
| +#include "chrome/browser/push_messaging/background_budget_service.h" |
| +#include "chrome/test/base/testing_profile.h" |
| +#include "content/public/test/test_browser_thread_bundle.h" |
| +#include "testing/gtest/include/gtest/gtest.h" |
| + |
| +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
|
| + |
| +const char kTestOrigin[] = "https://example.com"; |
| +const char kTestData[] = "1111101111"; |
| + |
| +} // namespace |
| + |
| +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.
|
| + public: |
| + BackgroundBudgetServiceTest() {} |
| + ~BackgroundBudgetServiceTest() override {} |
| + |
| + TestingProfile* profile() { return &profile_; } |
| + |
| + private: |
| + content::TestBrowserThreadBundle thread_bundle_; |
| + TestingProfile profile_; |
| +}; |
| + |
| +TEST_F(BackgroundBudgetServiceTest, GetBudgetFailure) { |
| + const GURL origin(kTestOrigin); |
| + |
| + std::string budget_string = |
| + 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!
|
| + |
| + 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.
|
| +} |
| + |
| +TEST_F(BackgroundBudgetServiceTest, GetBudgetSuccess) { |
| + const GURL origin(kTestOrigin); |
| + |
| + BackgroundBudgetService::StoreBudget(profile(), GURL(kTestOrigin), kTestData); |
| + |
| + std::string budget_string = |
| + BackgroundBudgetService::GetBudget(profile(), GURL(kTestOrigin)); |
| + |
| + EXPECT_EQ(budget_string, kTestData); |
| +} |