Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 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 "content/browser/background_fetch/background_fetch_data_manager.h" | |
| 6 | |
| 7 #include "content/browser/background_fetch/background_fetch_context.h" | |
| 8 #include "content/browser/background_fetch/fetch_request.h" | |
| 9 #include "content/browser/service_worker/service_worker_context_wrapper.h" | |
| 10 #include "content/public/test/test_browser_context.h" | |
| 11 #include "content/public/test/test_browser_thread_bundle.h" | |
| 12 #include "testing/gtest/include/gtest/gtest.h" | |
| 13 | |
| 14 namespace content { | |
| 15 | |
| 16 const char kOrigin[] = "https://example.com/"; | |
| 17 const char kResource[] = "https://example.com/resource.html"; | |
| 18 const char kTag[] = "TestRequestTag"; | |
| 19 | |
| 20 class BackgroundFetchDataManagerTest : public testing::Test { | |
| 21 protected: | |
| 22 BackgroundFetchDataManagerTest() | |
| 23 : browser_context_(new TestBrowserContext), | |
| 24 background_fetch_data_manager_( | |
| 25 new BackgroundFetchDataManager(new BackgroundFetchContext( | |
| 26 browser_context_.get(), | |
| 27 new ServiceWorkerContextWrapper(browser_context_.get())))) {} | |
|
Peter Beverloo
2017/02/13 18:35:06
I don't think this is OK. See EmbeddedWorkerTestHe
harkness
2017/02/14 13:52:46
Ah, that's a nifty helper class. Updated.
| |
| 28 | |
| 29 BackgroundFetchDataManager* GetDataManager() const { | |
| 30 return background_fetch_data_manager_.get(); | |
| 31 } | |
| 32 | |
| 33 private: | |
| 34 TestBrowserThreadBundle browser_thread_bundle_; | |
| 35 | |
| 36 std::unique_ptr<TestBrowserContext> browser_context_; | |
|
Peter Beverloo
2017/02/13 18:35:06
nit: no need to use an std::unique_ptr<>, just hav
harkness
2017/02/14 13:52:46
Done.
| |
| 37 std::unique_ptr<BackgroundFetchDataManager> background_fetch_data_manager_; | |
| 38 }; | |
| 39 | |
| 40 TEST_F(BackgroundFetchDataManagerTest, AddRequest) { | |
| 41 BackgroundFetchDataManager* data_manager = GetDataManager(); | |
| 42 FetchRequest request(url::Origin(GURL(kOrigin)), url::Origin(GURL(kResource)), | |
| 43 kTag, nullptr); | |
| 44 | |
| 45 data_manager->CreateRequest(request); | |
| 46 | |
| 47 // TODO(harkness) There's no output to test yet. Once there is, check that the | |
| 48 // request was actually added. | |
| 49 } | |
| 50 | |
| 51 } // namespace content | |
| OLD | NEW |