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

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

Issue 1542413002: Switch to standard integer types in chrome/browser/, part 1 of 4. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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 <stddef.h>
6 #include <stdint.h>
7
5 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
6 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
7 #include "base/files/scoped_temp_dir.h" 10 #include "base/files/scoped_temp_dir.h"
8 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
9 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
10 #include "base/observer_list.h" 13 #include "base/observer_list.h"
11 #include "base/strings/stringprintf.h" 14 #include "base/strings/stringprintf.h"
12 #include "base/test/test_file_util.h" 15 #include "base/test/test_file_util.h"
16 #include "build/build_config.h"
13 #include "chrome/browser/download/download_path_reservation_tracker.h" 17 #include "chrome/browser/download/download_path_reservation_tracker.h"
14 #include "chrome/browser/download/download_target_determiner.h" 18 #include "chrome/browser/download/download_target_determiner.h"
15 #include "content/public/test/mock_download_item.h" 19 #include "content/public/test/mock_download_item.h"
16 #include "content/public/test/test_browser_thread.h" 20 #include "content/public/test/test_browser_thread.h"
17 #include "testing/gmock/include/gmock/gmock.h" 21 #include "testing/gmock/include/gmock/gmock.h"
18 #include "testing/gtest/include/gtest/gtest.h" 22 #include "testing/gtest/include/gtest/gtest.h"
19 23
20 using content::BrowserThread; 24 using content::BrowserThread;
21 using content::DownloadItem; 25 using content::DownloadItem;
22 using content::MockDownloadItem; 26 using content::MockDownloadItem;
23 using testing::AnyNumber; 27 using testing::AnyNumber;
24 using testing::Return; 28 using testing::Return;
25 using testing::ReturnRef; 29 using testing::ReturnRef;
26 using testing::ReturnRefOfCopy; 30 using testing::ReturnRefOfCopy;
27 31
28 namespace { 32 namespace {
29 33
30 class DownloadPathReservationTrackerTest : public testing::Test { 34 class DownloadPathReservationTrackerTest : public testing::Test {
31 public: 35 public:
32 DownloadPathReservationTrackerTest(); 36 DownloadPathReservationTrackerTest();
33 37
34 // testing::Test 38 // testing::Test
35 void SetUp() override; 39 void SetUp() override;
36 void TearDown() override; 40 void TearDown() override;
37 41
38 MockDownloadItem* CreateDownloadItem(int32 id); 42 MockDownloadItem* CreateDownloadItem(int32_t id);
39 base::FilePath GetPathInDownloadsDirectory( 43 base::FilePath GetPathInDownloadsDirectory(
40 const base::FilePath::CharType* suffix); 44 const base::FilePath::CharType* suffix);
41 bool IsPathInUse(const base::FilePath& path); 45 bool IsPathInUse(const base::FilePath& path);
42 void CallGetReservedPath( 46 void CallGetReservedPath(
43 DownloadItem* download_item, 47 DownloadItem* download_item,
44 const base::FilePath& target_path, 48 const base::FilePath& target_path,
45 bool create_directory, 49 bool create_directory,
46 DownloadPathReservationTracker::FilenameConflictAction conflict_action, 50 DownloadPathReservationTracker::FilenameConflictAction conflict_action,
47 base::FilePath* return_path, 51 base::FilePath* return_path,
48 bool* return_verified); 52 bool* return_verified);
(...skipping 29 matching lines...) Expand all
78 void DownloadPathReservationTrackerTest::SetUp() { 82 void DownloadPathReservationTrackerTest::SetUp() {
79 ASSERT_TRUE(test_download_dir_.CreateUniqueTempDir()); 83 ASSERT_TRUE(test_download_dir_.CreateUniqueTempDir());
80 set_default_download_path(test_download_dir_.path()); 84 set_default_download_path(test_download_dir_.path());
81 } 85 }
82 86
83 void DownloadPathReservationTrackerTest::TearDown() { 87 void DownloadPathReservationTrackerTest::TearDown() {
84 message_loop_.RunUntilIdle(); 88 message_loop_.RunUntilIdle();
85 } 89 }
86 90
87 MockDownloadItem* DownloadPathReservationTrackerTest::CreateDownloadItem( 91 MockDownloadItem* DownloadPathReservationTrackerTest::CreateDownloadItem(
88 int32 id) { 92 int32_t id) {
89 MockDownloadItem* item = new ::testing::StrictMock<MockDownloadItem>; 93 MockDownloadItem* item = new ::testing::StrictMock<MockDownloadItem>;
90 EXPECT_CALL(*item, GetId()) 94 EXPECT_CALL(*item, GetId())
91 .WillRepeatedly(Return(id)); 95 .WillRepeatedly(Return(id));
92 EXPECT_CALL(*item, GetTargetFilePath()) 96 EXPECT_CALL(*item, GetTargetFilePath())
93 .WillRepeatedly(ReturnRefOfCopy(base::FilePath())); 97 .WillRepeatedly(ReturnRefOfCopy(base::FilePath()));
94 EXPECT_CALL(*item, GetState()) 98 EXPECT_CALL(*item, GetState())
95 .WillRepeatedly(Return(DownloadItem::IN_PROGRESS)); 99 .WillRepeatedly(Return(DownloadItem::IN_PROGRESS));
96 return item; 100 return item;
97 } 101 }
98 102
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 create_directory, 669 create_directory,
666 conflict_action, 670 conflict_action,
667 &reserved_path, 671 &reserved_path,
668 &verified); 672 &verified);
669 // We cannot truncate a path with very long extension. 673 // We cannot truncate a path with very long extension.
670 EXPECT_FALSE(verified); 674 EXPECT_FALSE(verified);
671 SetDownloadItemState(item.get(), DownloadItem::COMPLETE); 675 SetDownloadItemState(item.get(), DownloadItem::COMPLETE);
672 } 676 }
673 677
674 #endif 678 #endif
OLDNEW
« no previous file with comments | « chrome/browser/download/download_path_reservation_tracker.cc ('k') | chrome/browser/download/download_permission_request.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698