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

Side by Side Diff: components/offline_pages/core/downloads/download_ui_adapter_unittest.cc

Issue 2631933002: Adding status info to DownloadUIItem and piping it through. (Closed)
Patch Set: feedback, test compile Created 3 years, 11 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/offline_pages/core/downloads/download_ui_adapter.h" 5 #include "components/offline_pages/core/downloads/download_ui_adapter.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <map> 9 #include <map>
10 #include <memory> 10 #include <memory>
(...skipping 29 matching lines...) Expand all
40 static const ClientId kTestClientIdOtherGuid(kLastNNamespace, kTestBadGuid); 40 static const ClientId kTestClientIdOtherGuid(kLastNNamespace, kTestBadGuid);
41 static const ClientId kTestClientId1(kAsyncNamespace, kTestGuid1); 41 static const ClientId kTestClientId1(kAsyncNamespace, kTestGuid1);
42 static const ClientId kTestClientId2(kAsyncNamespace, kTestGuid2); 42 static const ClientId kTestClientId2(kAsyncNamespace, kTestGuid2);
43 static const base::FilePath kTestFilePath = 43 static const base::FilePath kTestFilePath =
44 base::FilePath(FILE_PATH_LITERAL("foo/bar.mhtml")); 44 base::FilePath(FILE_PATH_LITERAL("foo/bar.mhtml"));
45 static const int kFileSize = 1000; 45 static const int kFileSize = 1000;
46 static const base::Time kTestCreationTime = base::Time::Now(); 46 static const base::Time kTestCreationTime = base::Time::Now();
47 static const base::string16 kTestTitle = base::ASCIIToUTF16("test title"); 47 static const base::string16 kTestTitle = base::ASCIIToUTF16("test title");
48 } // namespace 48 } // namespace
49 49
50 // Mock DownloadUIAdapter::Delegate
51 class DownloadUIAdapterDelegate : public DownloadUIAdapter::Delegate {
52 public:
53 DownloadUIAdapterDelegate() {
54 }
55 ~DownloadUIAdapterDelegate() override {}
56
57 // DownloadUIAdapter::Delegate
58 bool IsVisibleInUI(const ClientId& client_id) override { return true; }
59 bool IsTemporaryHiddenInUI(const ClientId& client_id) override {
60 return false;
61 }
62 };
63
50 // Mock OfflinePageModel for testing the SavePage calls. 64 // Mock OfflinePageModel for testing the SavePage calls.
51 class MockOfflinePageModel : public StubOfflinePageModel { 65 class MockOfflinePageModel : public StubOfflinePageModel {
52 public: 66 public:
53 MockOfflinePageModel(base::TestMockTimeTaskRunner* task_runner) 67 MockOfflinePageModel(base::TestMockTimeTaskRunner* task_runner)
54 : observer_(nullptr), 68 : observer_(nullptr),
55 task_runner_(task_runner), 69 task_runner_(task_runner),
56 policy_controller_(new ClientPolicyController()) { 70 policy_controller_(new ClientPolicyController()) {
57 adapter.reset(new DownloadUIAdapter(this)); 71 DownloadUIAdapterDelegate* delegate = new DownloadUIAdapterDelegate(this, )
72 adapter.reset(new DownloadUIAdapter(this, ));
58 // Add one page. 73 // Add one page.
59 OfflinePageItem page(GURL(kTestUrl), kTestOfflineId1, kTestClientId1, 74 OfflinePageItem page(GURL(kTestUrl), kTestOfflineId1, kTestClientId1,
60 kTestFilePath, kFileSize, kTestCreationTime); 75 kTestFilePath, kFileSize, kTestCreationTime);
61 page.title = kTestTitle; 76 page.title = kTestTitle;
62 pages[kTestOfflineId1] = page; 77 pages[kTestOfflineId1] = page;
63 } 78 }
64 79
65 ~MockOfflinePageModel() override {} 80 ~MockOfflinePageModel() override {}
66 81
67 // OfflinePageModel overrides. 82 // OfflinePageModel overrides.
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 model->adapter->RemoveObserver(this); 282 model->adapter->RemoveObserver(this);
268 // This will complete async fetch of items, but... 283 // This will complete async fetch of items, but...
269 PumpLoop(); 284 PumpLoop();
270 // items should not be loaded when there is no observers! 285 // items should not be loaded when there is no observers!
271 EXPECT_FALSE(items_loaded); 286 EXPECT_FALSE(items_loaded);
272 // This should not crash. 287 // This should not crash.
273 model->adapter->AddObserver(this); 288 model->adapter->AddObserver(this);
274 } 289 }
275 290
276 } // namespace offline_pages 291 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698