Chromium Code Reviews| Index: components/offline_pages/background/request_coordinator_unittest.cc |
| diff --git a/components/offline_pages/background/request_coordinator_unittest.cc b/components/offline_pages/background/request_coordinator_unittest.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..55df010009cdee146698fc2f0f4ff63dcc520cd7 |
| --- /dev/null |
| +++ b/components/offline_pages/background/request_coordinator_unittest.cc |
| @@ -0,0 +1,49 @@ |
| +// 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 "components/offline_pages/background/request_coordinator.h" |
| + |
| +#include "base/bind.h" |
| +#include "base/memory/weak_ptr.h" |
| +#include "components/offline_pages/background/save_page_request.h" |
| +#include "testing/gtest/include/gtest/gtest.h" |
| + |
| +namespace offline_pages { |
| + |
| +namespace { |
| +// put test constants here |
| +const int64_t kRequestId = 42; |
| +const GURL kUrl("http://universe.com/everything"); |
| +const ClientId kClientId("bookmark", "1234"); |
| +} // namespace |
| + |
| +class RequestCoordinatorTest |
| + : public testing::Test, |
| + public base::SupportsWeakPtr<RequestCoordinatorTest> { |
| + public: |
| + 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
|
| + ~RequestCoordinatorTest() override; |
| + |
| + 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.
|
| + } |
| +}; |
| + |
| +RequestCoordinatorTest::RequestCoordinatorTest() {} |
| + |
| +RequestCoordinatorTest::~RequestCoordinatorTest() {} |
| + |
| +TEST_F(RequestCoordinatorTest, StartProcessingWithNoRequests) { |
| + RequestCoordinator::ProcessingDoneCallback callback = |
| + 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.
|
| + RequestCoordinator coordinator; |
| + EXPECT_FALSE(coordinator.StartProcessing(callback)); |
| +} |
| + |
| +TEST_F(RequestCoordinatorTest, SavePageLater) { |
| + RequestCoordinator coordinator; |
| + SavePageRequest request(kRequestId, kUrl, kClientId, base::Time::Now()); |
| + EXPECT_TRUE(coordinator.SavePageLater(request)); |
| +} |
| + |
| +} // namespace offline_pages |