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

Side by Side Diff: chrome/browser/ui/webui/md_downloads/downloads_list_tracker_unittest.cc

Issue 1865213004: Convert //chrome/browser/ui from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "chrome/browser/ui/webui/md_downloads/downloads_list_tracker.h" 5 #include "chrome/browser/ui/webui/md_downloads/downloads_list_tracker.h"
6 6
7 #include <limits.h> 7 #include <limits.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory>
10 #include <vector> 11 #include <vector>
11 12
12 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/stl_util.h" 14 #include "base/stl_util.h"
15 #include "base/time/time.h" 15 #include "base/time/time.h"
16 #include "chrome/browser/download/download_item_model.h" 16 #include "chrome/browser/download/download_item_model.h"
17 #include "chrome/test/base/testing_profile.h" 17 #include "chrome/test/base/testing_profile.h"
18 #include "content/public/test/mock_download_item.h" 18 #include "content/public/test/mock_download_item.h"
19 #include "content/public/test/mock_download_manager.h" 19 #include "content/public/test/mock_download_manager.h"
20 #include "content/public/test/test_browser_thread_bundle.h" 20 #include "content/public/test/test_browser_thread_bundle.h"
21 #include "content/public/test/test_web_ui.h" 21 #include "content/public/test/test_web_ui.h"
22 #include "testing/gmock/include/gmock/gmock.h" 22 #include "testing/gmock/include/gmock/gmock.h"
23 #include "testing/gtest/include/gtest/gtest.h" 23 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 TestDownloadsListTracker(content::DownloadManager* manager, 78 TestDownloadsListTracker(content::DownloadManager* manager,
79 content::WebUI* web_ui) 79 content::WebUI* web_ui)
80 : DownloadsListTracker(manager, web_ui, base::Bind(&ShouldShowItem)) {} 80 : DownloadsListTracker(manager, web_ui, base::Bind(&ShouldShowItem)) {}
81 ~TestDownloadsListTracker() override {} 81 ~TestDownloadsListTracker() override {}
82 82
83 using DownloadsListTracker::IsIncognito; 83 using DownloadsListTracker::IsIncognito;
84 using DownloadsListTracker::GetItemForTesting; 84 using DownloadsListTracker::GetItemForTesting;
85 using DownloadsListTracker::SetChunkSizeForTesting; 85 using DownloadsListTracker::SetChunkSizeForTesting;
86 86
87 protected: 87 protected:
88 scoped_ptr<base::DictionaryValue> CreateDownloadItemValue( 88 std::unique_ptr<base::DictionaryValue> CreateDownloadItemValue(
89 content::DownloadItem* item) const override { 89 content::DownloadItem* item) const override {
90 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue); 90 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue);
91 CHECK_LE(item->GetId(), static_cast<uint64_t>(INT_MAX)); 91 CHECK_LE(item->GetId(), static_cast<uint64_t>(INT_MAX));
92 dict->SetInteger("id", item->GetId()); 92 dict->SetInteger("id", item->GetId());
93 return dict; 93 return dict;
94 } 94 }
95 }; 95 };
96 96
97 // A fixture to test DownloadsListTracker. 97 // A fixture to test DownloadsListTracker.
98 class DownloadsListTrackerTest : public testing::Test { 98 class DownloadsListTrackerTest : public testing::Test {
99 public: 99 public:
100 DownloadsListTrackerTest() {} 100 DownloadsListTrackerTest() {}
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 for (auto* mock_item : mock_items_) 141 for (auto* mock_item : mock_items_)
142 result->push_back(mock_item); 142 result->push_back(mock_item);
143 } 143 }
144 144
145 // NOTE: The initialization order of these members matters. 145 // NOTE: The initialization order of these members matters.
146 content::TestBrowserThreadBundle thread_bundle_; 146 content::TestBrowserThreadBundle thread_bundle_;
147 TestingProfile profile_; 147 TestingProfile profile_;
148 148
149 testing::NiceMock<content::MockDownloadManager> manager_; 149 testing::NiceMock<content::MockDownloadManager> manager_;
150 content::TestWebUI web_ui_; 150 content::TestWebUI web_ui_;
151 scoped_ptr<TestDownloadsListTracker> tracker_; 151 std::unique_ptr<TestDownloadsListTracker> tracker_;
152 152
153 std::vector<MockDownloadItem*> mock_items_; 153 std::vector<MockDownloadItem*> mock_items_;
154 }; 154 };
155 155
156 TEST_F(DownloadsListTrackerTest, SetSearchTerms) { 156 TEST_F(DownloadsListTrackerTest, SetSearchTerms) {
157 CreateTracker(); 157 CreateTracker();
158 158
159 const base::ListValue empty_terms; 159 const base::ListValue empty_terms;
160 EXPECT_FALSE(tracker()->SetSearchTerms(empty_terms)); 160 EXPECT_FALSE(tracker()->SetSearchTerms(empty_terms));
161 161
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 EXPECT_EQ(1u, GetIds(web_ui()->call_data()[0]->arg2()).size()); 353 EXPECT_EQ(1u, GetIds(web_ui()->call_data()[0]->arg2()).size());
354 354
355 DownloadItemModel(unsent_item).SetShouldShowInShelf(false); 355 DownloadItemModel(unsent_item).SetShouldShowInShelf(false);
356 tracker()->OnDownloadUpdated(manager(), unsent_item); 356 tracker()->OnDownloadUpdated(manager(), unsent_item);
357 EXPECT_EQ(1u, web_ui()->call_data().size()); 357 EXPECT_EQ(1u, web_ui()->call_data().size());
358 358
359 DownloadItemModel(unsent_item).SetShouldShowInShelf(true); 359 DownloadItemModel(unsent_item).SetShouldShowInShelf(true);
360 tracker()->OnDownloadUpdated(manager(), unsent_item); 360 tracker()->OnDownloadUpdated(manager(), unsent_item);
361 EXPECT_EQ(1u, web_ui()->call_data().size()); 361 EXPECT_EQ(1u, web_ui()->call_data().size());
362 } 362 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/md_downloads/downloads_list_tracker.cc ('k') | chrome/browser/ui/webui/media/webrtc_logs_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698