OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 <shlwapi.h> | 5 #include <shlwapi.h> |
6 #include <sstream> | 6 #include <sstream> |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 | 66 |
67 class DownloadTest : public UITest { | 67 class DownloadTest : public UITest { |
68 protected: | 68 protected: |
69 DownloadTest() : UITest() {} | 69 DownloadTest() : UITest() {} |
70 | 70 |
71 void CleanUpDownload(const std::wstring& client_filename, | 71 void CleanUpDownload(const std::wstring& client_filename, |
72 const std::wstring& server_filename) { | 72 const std::wstring& server_filename) { |
73 // Find the path on the client. | 73 // Find the path on the client. |
74 std::wstring file_on_client(download_prefix_); | 74 std::wstring file_on_client(download_prefix_); |
75 file_on_client.append(client_filename); | 75 file_on_client.append(client_filename); |
76 EXPECT_PRED1(file_util::PathExists, file_on_client); | 76 EXPECT_TRUE(file_util::PathExists(file_on_client)); |
77 | 77 |
78 // Find the path on the server. | 78 // Find the path on the server. |
79 std::wstring file_on_server; | 79 std::wstring file_on_server; |
80 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, | 80 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, |
81 &file_on_server)); | 81 &file_on_server)); |
82 file_on_server.append(L"\\"); | 82 file_on_server.append(L"\\"); |
83 file_on_server.append(server_filename); | 83 file_on_server.append(server_filename); |
84 ASSERT_TRUE(file_util::PathExists(file_on_server)); | 84 ASSERT_TRUE(file_util::PathExists(file_on_server)); |
85 | 85 |
86 // Check that we downloaded the file correctly. | 86 // Check that we downloaded the file correctly. |
87 EXPECT_PRED2(file_util::ContentsEqual, file_on_server, file_on_client); | 87 EXPECT_TRUE(file_util::ContentsEqual(file_on_server, |
| 88 file_on_client)); |
88 | 89 |
89 // Check if the Zone Identifier is correclty set. | 90 // Check if the Zone Identifier is correclty set. |
90 if (VolumeSupportsADS(file_on_client)) | 91 if (VolumeSupportsADS(file_on_client)) |
91 CheckZoneIdentifier(file_on_client); | 92 CheckZoneIdentifier(file_on_client); |
92 | 93 |
93 // Delete the client copy of the file. | 94 // Delete the client copy of the file. |
94 EXPECT_PRED2(file_util::Delete, file_on_client, false); | 95 EXPECT_TRUE(file_util::Delete(file_on_client, false)); |
95 } | 96 } |
96 | 97 |
97 void CleanUpDownload(const std::wstring& file) { | 98 void CleanUpDownload(const std::wstring& file) { |
98 CleanUpDownload(file, file); | 99 CleanUpDownload(file, file); |
99 } | 100 } |
100 | 101 |
101 virtual void SetUp() { | 102 virtual void SetUp() { |
102 UITest::SetUp(); | 103 UITest::SetUp(); |
103 download_prefix_ = GetDownloadDirectory(); | 104 download_prefix_ = GetDownloadDirectory(); |
104 download_prefix_ += file_util::kPathSeparator; | 105 download_prefix_ += file_util::kPathSeparator; |
(...skipping 19 matching lines...) Expand all Loading... |
124 EXPECT_EQ(2, GetTabCount()); | 125 EXPECT_EQ(2, GetTabCount()); |
125 // TODO(tc): check download status text | 126 // TODO(tc): check download status text |
126 | 127 |
127 // Make sure the download shelf is showing. | 128 // Make sure the download shelf is showing. |
128 scoped_ptr<TabProxy> dl_tab(window->GetTab(0)); | 129 scoped_ptr<TabProxy> dl_tab(window->GetTab(0)); |
129 ASSERT_TRUE(dl_tab.get()); | 130 ASSERT_TRUE(dl_tab.get()); |
130 EXPECT_TRUE(WaitForDownloadShelfVisible(dl_tab.get())); | 131 EXPECT_TRUE(WaitForDownloadShelfVisible(dl_tab.get())); |
131 } | 132 } |
132 | 133 |
133 std::wstring filename = file_util::GetFilenameFromPath(url); | 134 std::wstring filename = file_util::GetFilenameFromPath(url); |
134 EXPECT_PRED1(file_util::PathExists, download_prefix_ + filename); | 135 EXPECT_TRUE(file_util::PathExists(download_prefix_ + filename)); |
135 | 136 |
136 // Delete the file we just downloaded. | 137 // Delete the file we just downloaded. |
137 for (int i = 0; i < 10; ++i) { | 138 for (int i = 0; i < 10; ++i) { |
138 if (file_util::Delete(download_prefix_ + filename, false)) | 139 if (file_util::Delete(download_prefix_ + filename, false)) |
139 break; | 140 break; |
140 Sleep(kWaitForActionMaxMsec / 10); | 141 Sleep(kWaitForActionMaxMsec / 10); |
141 } | 142 } |
142 EXPECT_FALSE(file_util::PathExists(download_prefix_ + filename)); | 143 EXPECT_FALSE(file_util::PathExists(download_prefix_ + filename)); |
143 } | 144 } |
144 | 145 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 RunSizeTest(url, L"32.0 KB - " + filename, L"100% - " + filename); | 233 RunSizeTest(url, L"32.0 KB - " + filename, L"100% - " + filename); |
233 } | 234 } |
234 | 235 |
235 // http://b/1158253 | 236 // http://b/1158253 |
236 TEST_F(DownloadTest, DISABLED_KnownSize) { | 237 TEST_F(DownloadTest, DISABLED_KnownSize) { |
237 std::wstring url(URLRequestSlowDownloadJob::kKnownSizeUrl); | 238 std::wstring url(URLRequestSlowDownloadJob::kKnownSizeUrl); |
238 std::wstring filename = file_util::GetFilenameFromPath(url); | 239 std::wstring filename = file_util::GetFilenameFromPath(url); |
239 RunSizeTest(url, L"71% - " + filename, L"100% - " + filename); | 240 RunSizeTest(url, L"71% - " + filename, L"100% - " + filename); |
240 } | 241 } |
241 | 242 |
OLD | NEW |