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

Side by Side Diff: net/url_request/url_request_unittest.cc

Issue 9074: Port more of url_request_unittest.cc.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 12 years, 1 month 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 | Annotate | Revision Log
« base/file_util.cc ('K') | « base/file_util_win.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "net/url_request/url_request_unittest.h" 5 #include "net/url_request/url_request_unittest.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windows.h> 8 #include <windows.h>
9 #include <shlobj.h> 9 #include <shlobj.h>
10 #endif 10 #endif
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 r.AppendFileToUpload(path); 324 r.AppendFileToUpload(path);
325 325
326 // This file should just be ignored in the upload stream. 326 // This file should just be ignored in the upload stream.
327 r.AppendFileToUpload(L"c:\\path\\to\\non\\existant\\file.randomness.12345"); 327 r.AppendFileToUpload(L"c:\\path\\to\\non\\existant\\file.randomness.12345");
328 328
329 r.Start(); 329 r.Start();
330 EXPECT_TRUE(r.is_pending()); 330 EXPECT_TRUE(r.is_pending());
331 331
332 MessageLoop::current()->Run(); 332 MessageLoop::current()->Run();
333 333
334 #if defined(OS_WIN) 334 int64 size;
335 HANDLE file = CreateFile(path.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, 335 ASSERT_EQ(true, file_util::GetFileSize(path, &size));
336 OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
337 ASSERT_NE(INVALID_HANDLE_VALUE, file);
338
339 DWORD size = GetFileSize(file, NULL);
340 scoped_array<char> buf(new char[size]); 336 scoped_array<char> buf(new char[size]);
341 337
342 DWORD size_read; 338 int64 size_read = file_util::ReadFile(path, buf.get(), size);
343 EXPECT_TRUE(ReadFile(file, buf.get(), size, &size_read, NULL)); 339 ASSERT_EQ(size, size_read);
344
345 CloseHandle(file);
346
347 EXPECT_EQ(size, size_read);
348 340
349 ASSERT_EQ(1, d.response_started_count()) << "request failed: " << 341 ASSERT_EQ(1, d.response_started_count()) << "request failed: " <<
350 (int) r.status().status() << ", os error: " << r.status().os_error(); 342 (int) r.status().status() << ", os error: " << r.status().os_error();
351 343
352 EXPECT_FALSE(d.received_data_before_response()); 344 EXPECT_FALSE(d.received_data_before_response());
353 345
354 ASSERT_EQ(size, d.bytes_received()); 346 ASSERT_EQ(size, d.bytes_received());
355 EXPECT_EQ(0, memcmp(d.data_received().c_str(), buf.get(), size)); 347 EXPECT_EQ(0, memcmp(d.data_received().c_str(), buf.get(), size));
356 #else
357 NOTIMPLEMENTED();
358 #endif
359 } 348 }
360 #ifndef NDEBUG 349 #ifndef NDEBUG
361 DCHECK_EQ(url_request_metrics.object_count,0); 350 DCHECK_EQ(url_request_metrics.object_count,0);
362 #endif 351 #endif
363 } 352 }
364 353
365 TEST(URLRequestTest, AboutBlankTest) { 354 TEST(URLRequestTest, AboutBlankTest) {
366 TestDelegate d; 355 TestDelegate d;
367 { 356 {
368 TestURLRequest r(GURL("about:blank"), &d); 357 TestURLRequest r(GURL("about:blank"), &d);
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
770 MessageLoop::current()->Run(); 759 MessageLoop::current()->Run();
771 760
772 EXPECT_TRUE(d.data_received().find("user/secret") != std::string::npos); 761 EXPECT_TRUE(d.data_received().find("user/secret") != std::string::npos);
773 762
774 // Should be the same cached document, which means that the response time 763 // Should be the same cached document, which means that the response time
775 // should not have changed. 764 // should not have changed.
776 EXPECT_TRUE(response_time == r.response_time()); 765 EXPECT_TRUE(response_time == r.response_time());
777 } 766 }
778 } 767 }
779 768
OLDNEW
« base/file_util.cc ('K') | « base/file_util_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698