Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 "components/offline_pages/background/request_coordinator.h" | |
| 6 | |
| 7 #include "base/bind.h" | |
| 8 #include "base/memory/weak_ptr.h" | |
| 9 #include "components/offline_pages/background/save_page_request.h" | |
| 10 #include "testing/gtest/include/gtest/gtest.h" | |
| 11 | |
| 12 namespace offline_pages { | |
| 13 | |
| 14 namespace { | |
| 15 // put test constants here | |
| 16 const int64_t kRequestId = 42; | |
| 17 const GURL kUrl("http://universe.com/everything"); | |
| 18 const ClientId kClientId("bookmark", "1234"); | |
| 19 } // namespace | |
| 20 | |
| 21 class RequestCoordinatorTest | |
| 22 : public testing::Test, | |
| 23 public base::SupportsWeakPtr<RequestCoordinatorTest> { | |
| 24 public: | |
| 25 RequestCoordinatorTest(); | |
|
fgorski
2016/05/04 17:39:44
nit: likely not needed.
Pete Williamson
2016/05/04 18:17:42
I prefer to define these explicitly instead of let
| |
| 26 ~RequestCoordinatorTest() override; | |
| 27 | |
| 28 void callbackFunction() { | |
|
fgorski
2016/05/04 17:39:44
nit: use PascalCase not camelCase in C++
Pete Williamson
2016/05/04 18:17:42
Done.
| |
| 29 } | |
| 30 }; | |
| 31 | |
| 32 RequestCoordinatorTest::RequestCoordinatorTest() {} | |
| 33 | |
| 34 RequestCoordinatorTest::~RequestCoordinatorTest() {} | |
| 35 | |
| 36 TEST_F(RequestCoordinatorTest, StartProcessingWithNoRequests) { | |
| 37 RequestCoordinator::ProcessingDoneCallback callback = | |
| 38 base::Bind(&RequestCoordinatorTest::callbackFunction, AsWeakPtr()); | |
|
fgorski
2016/05/04 17:39:44
You can use base::Unretained in tests and not worr
Pete Williamson
2016/05/04 18:17:42
Done.
| |
| 39 RequestCoordinator coordinator; | |
| 40 EXPECT_FALSE(coordinator.StartProcessing(callback)); | |
| 41 } | |
| 42 | |
| 43 TEST_F(RequestCoordinatorTest, SavePageLater) { | |
| 44 RequestCoordinator coordinator; | |
| 45 SavePageRequest request(kRequestId, kUrl, kClientId, base::Time::Now()); | |
| 46 EXPECT_TRUE(coordinator.SavePageLater(request)); | |
| 47 } | |
| 48 | |
| 49 } // namespace offline_pages | |
| OLD | NEW |