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

Side by Side Diff: components/offline_pages/background/request_coordinator_unittest.cc

Issue 1950733002: Add unit test for request coordiator (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 "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("life", "1234");
fgorski 2016/05/03 22:55:49 can we have some test namespace name, that will wo
Pete Williamson 2016/05/04 17:29:27 Done.
19
20
dougarnett 2016/05/03 22:42:06 drop extra line?
Pete Williamson 2016/05/03 22:51:47 Done.
21 // any helper functions that we need to here
22 } // namespace
23
24 class RequestCoordinatorTest
25 : public testing::Test,
26 public base::SupportsWeakPtr<RequestCoordinatorTest> {
27 public:
28 RequestCoordinatorTest();
29 ~RequestCoordinatorTest() override;
30
31 void SetUp() override;
32 void TearDown() override;
33
34 void callbackFunction() {
35 // Notify that we have been called
36 callback_called = true;
37 }
38
39 private:
40 // Any test class data we might need
41 bool callback_called;
fgorski 2016/05/03 22:55:50 callback_called_ Remove please if you don't inten
Pete Williamson 2016/05/04 17:29:27 Done.
42 };
43
44 RequestCoordinatorTest::RequestCoordinatorTest() {}
45
46 RequestCoordinatorTest::~RequestCoordinatorTest() {}
47
48 void RequestCoordinatorTest::SetUp() {
49 callback_called = false;
50 }
51
52 void RequestCoordinatorTest::TearDown() {
fgorski 2016/05/03 22:55:50 not needed.
Pete Williamson 2016/05/04 17:29:27 Done.
53 }
54
55 /* Test with out/d/bin/run_components_unittests -vv -f RequestCoordinator* */
fgorski 2016/05/03 22:55:50 Don't put that in. Perhaps this go in the test sec
Pete Williamson 2016/05/04 17:29:27 Done.
56
57 TEST_F(RequestCoordinatorTest, StartProcessingTest) {
fgorski 2016/05/03 22:55:50 don't append test to method name. You already have
Pete Williamson 2016/05/04 17:29:27 Done.
58 RequestCoordinator::ProcessingDoneCallback callback =
59 base::Bind(&RequestCoordinatorTest::callbackFunction, AsWeakPtr());
60 RequestCoordinator coordinator;
fgorski 2016/05/03 22:55:50 please add a comment above explaining what you are
Pete Williamson 2016/05/04 17:29:27 Done.
61 bool return_value = coordinator.StartProcessing(callback);
fgorski 2016/05/03 22:55:50 this and next is a single line.
Pete Williamson 2016/05/04 17:29:27 Done.
62 EXPECT_FALSE(return_value);
63 }
64
65 TEST_F(RequestCoordinatorTest, SavePageLaterTest) {
fgorski 2016/05/03 22:55:49 remove Test from second part.
Pete Williamson 2016/05/04 17:29:27 Done.
66 RequestCoordinator coordinator;
67 SavePageRequest request(kRequestId, kUrl, kClientId, base::Time::Now());
68 bool return_value = coordinator.SavePageLater(request);
fgorski 2016/05/03 22:55:50 single line.
Pete Williamson 2016/05/04 17:29:27 Done.
69 EXPECT_TRUE(return_value);
70 }
71
72 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698