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

Side by Side Diff: chrome/browser/download/download_shelf_unittest.cc

Issue 2799883003: Switch from TestBrowserThread to TestBrowserThreadBundle in chrome. (Closed)
Patch Set: fix-string Created 3 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <memory> 5 #include <memory>
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/message_loop/message_loop.h"
9 #include "base/run_loop.h" 8 #include "base/run_loop.h"
10 #include "chrome/browser/chrome_notification_types.h" 9 #include "chrome/browser/chrome_notification_types.h"
11 #include "chrome/browser/download/download_item_model.h" 10 #include "chrome/browser/download/download_item_model.h"
12 #include "chrome/browser/download/download_service_factory.h" 11 #include "chrome/browser/download/download_service_factory.h"
13 #include "chrome/browser/download/download_service_impl.h" 12 #include "chrome/browser/download/download_service_impl.h"
14 #include "chrome/browser/download/test_download_shelf.h" 13 #include "chrome/browser/download/test_download_shelf.h"
15 #include "chrome/test/base/testing_profile.h" 14 #include "chrome/test/base/testing_profile.h"
16 #include "content/public/browser/notification_service.h" 15 #include "content/public/browser/notification_service.h"
17 #include "content/public/test/mock_download_item.h" 16 #include "content/public/test/mock_download_item.h"
18 #include "content/public/test/mock_download_manager.h" 17 #include "content/public/test/mock_download_manager.h"
19 #include "content/public/test/test_browser_thread.h" 18 #include "content/public/test/test_browser_thread_bundle.h"
20 #include "extensions/common/extension.h" 19 #include "extensions/common/extension.h"
21 #include "testing/gmock/include/gmock/gmock.h" 20 #include "testing/gmock/include/gmock/gmock.h"
22 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
23 22
24 using ::testing::Return; 23 using ::testing::Return;
25 using ::testing::ReturnRefOfCopy; 24 using ::testing::ReturnRefOfCopy;
26 using ::testing::SaveArg; 25 using ::testing::SaveArg;
27 using ::testing::_; 26 using ::testing::_;
28 using content::DownloadItem; 27 using content::DownloadItem;
29 28
(...skipping 17 matching lines...) Expand all
47 46
48 void SetUp() override { 47 void SetUp() override {
49 } 48 }
50 49
51 void TearDown() override { 50 void TearDown() override {
52 } 51 }
53 52
54 private: 53 private:
55 std::unique_ptr<content::MockDownloadItem> GetInProgressMockDownload(); 54 std::unique_ptr<content::MockDownloadItem> GetInProgressMockDownload();
56 55
57 base::MessageLoopForUI message_loop_; 56 content::TestBrowserThreadBundle test_browser_thread_bundle_;
58 content::TestBrowserThread ui_thread_;
59 std::unique_ptr<content::MockDownloadItem> download_item_; 57 std::unique_ptr<content::MockDownloadItem> download_item_;
60 std::unique_ptr<content::MockDownloadManager> download_manager_; 58 std::unique_ptr<content::MockDownloadManager> download_manager_;
61 TestDownloadShelf shelf_; 59 TestDownloadShelf shelf_;
62 std::unique_ptr<TestingProfile> profile_; 60 std::unique_ptr<TestingProfile> profile_;
63 }; 61 };
64 62
65 DownloadShelfTest::DownloadShelfTest() 63 DownloadShelfTest::DownloadShelfTest() : profile_(new TestingProfile()) {
66 : ui_thread_(content::BrowserThread::UI, &message_loop_),
67 profile_(new TestingProfile()) {
68 download_item_.reset(new ::testing::NiceMock<content::MockDownloadItem>()); 64 download_item_.reset(new ::testing::NiceMock<content::MockDownloadItem>());
69 ON_CALL(*download_item_, GetAutoOpened()).WillByDefault(Return(false)); 65 ON_CALL(*download_item_, GetAutoOpened()).WillByDefault(Return(false));
70 ON_CALL(*download_item_, GetMimeType()).WillByDefault(Return("text/plain")); 66 ON_CALL(*download_item_, GetMimeType()).WillByDefault(Return("text/plain"));
71 ON_CALL(*download_item_, GetOpenWhenComplete()).WillByDefault(Return(false)); 67 ON_CALL(*download_item_, GetOpenWhenComplete()).WillByDefault(Return(false));
72 ON_CALL(*download_item_, GetTargetDisposition()) 68 ON_CALL(*download_item_, GetTargetDisposition())
73 .WillByDefault(Return(DownloadItem::TARGET_DISPOSITION_OVERWRITE)); 69 .WillByDefault(Return(DownloadItem::TARGET_DISPOSITION_OVERWRITE));
74 ON_CALL(*download_item_, GetURL()) 70 ON_CALL(*download_item_, GetURL())
75 .WillByDefault(ReturnRefOfCopy(GURL("http://example.com/foo"))); 71 .WillByDefault(ReturnRefOfCopy(GURL("http://example.com/foo")));
76 ON_CALL(*download_item_, GetState()) 72 ON_CALL(*download_item_, GetState())
77 .WillByDefault(Return(DownloadItem::IN_PROGRESS)); 73 .WillByDefault(Return(DownloadItem::IN_PROGRESS));
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 .WillRepeatedly(Return(false)); 195 .WillRepeatedly(Return(false));
200 ASSERT_FALSE(DownloadItemModel(download_item()) 196 ASSERT_FALSE(DownloadItemModel(download_item())
201 .ShouldRemoveFromShelfWhenComplete()); 197 .ShouldRemoveFromShelfWhenComplete());
202 198
203 base::RunLoop run_loop; 199 base::RunLoop run_loop;
204 run_loop.RunUntilIdle(); 200 run_loop.RunUntilIdle();
205 201
206 EXPECT_TRUE(shelf()->did_add_download()); 202 EXPECT_TRUE(shelf()->did_add_download());
207 EXPECT_TRUE(shelf()->IsShowing()); 203 EXPECT_TRUE(shelf()->IsShowing());
208 } 204 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698