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

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

Issue 11050009: Use ScopedCOMInitializer in more places. While this doesn't always simplify code, it does mean we … (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 2 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 | Annotate | Revision Log
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 "build/build_config.h" 5 #include "build/build_config.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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 #include "net/url_request/url_request_file_dir_job.h" 57 #include "net/url_request/url_request_file_dir_job.h"
58 #include "net/url_request/url_request_http_job.h" 58 #include "net/url_request/url_request_http_job.h"
59 #include "net/url_request/url_request_job_factory_impl.h" 59 #include "net/url_request/url_request_job_factory_impl.h"
60 #include "net/url_request/url_request_redirect_job.h" 60 #include "net/url_request/url_request_redirect_job.h"
61 #include "net/url_request/url_request_test_job.h" 61 #include "net/url_request/url_request_test_job.h"
62 #include "net/url_request/url_request_test_util.h" 62 #include "net/url_request/url_request_test_util.h"
63 #include "testing/gtest/include/gtest/gtest.h" 63 #include "testing/gtest/include/gtest/gtest.h"
64 #include "testing/platform_test.h" 64 #include "testing/platform_test.h"
65 65
66 #if defined(OS_WIN) 66 #if defined(OS_WIN)
67 #include "base/win/scoped_com_initializer.h"
67 #include "base/win/windows_version.h" 68 #include "base/win/windows_version.h"
68 #endif 69 #endif
69 70
70 using base::Time; 71 using base::Time;
71 72
72 namespace net { 73 namespace net {
73 74
74 namespace { 75 namespace {
75 76
76 const string16 kChrome(ASCIIToUTF16("chrome")); 77 const string16 kChrome(ASCIIToUTF16("chrome"));
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 TEST_F(URLRequestTest, ResolveShortcutTest) { 696 TEST_F(URLRequestTest, ResolveShortcutTest) {
696 FilePath app_path; 697 FilePath app_path;
697 PathService::Get(base::DIR_SOURCE_ROOT, &app_path); 698 PathService::Get(base::DIR_SOURCE_ROOT, &app_path);
698 app_path = app_path.AppendASCII("net"); 699 app_path = app_path.AppendASCII("net");
699 app_path = app_path.AppendASCII("data"); 700 app_path = app_path.AppendASCII("data");
700 app_path = app_path.AppendASCII("url_request_unittest"); 701 app_path = app_path.AppendASCII("url_request_unittest");
701 app_path = app_path.AppendASCII("with-headers.html"); 702 app_path = app_path.AppendASCII("with-headers.html");
702 703
703 std::wstring lnk_path = app_path.value() + L".lnk"; 704 std::wstring lnk_path = app_path.value() + L".lnk";
704 705
705 CoInitialize(NULL); 706 base::win::ScopedCOMInitializer com_initializer_;
Ryan Sleevi 2012/10/03 12:50:43 nit: naming
706 707
707 // Temporarily create a shortcut for test 708 // Temporarily create a shortcut for test
708 IShellLink* shell = NULL; 709 IShellLink* shell = NULL;
709 ASSERT_TRUE(SUCCEEDED(CoCreateInstance( 710 ASSERT_TRUE(SUCCEEDED(CoCreateInstance(
710 CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, 711 CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink,
711 reinterpret_cast<LPVOID*>(&shell)))); 712 reinterpret_cast<LPVOID*>(&shell))));
712 IPersistFile* persist = NULL; 713 IPersistFile* persist = NULL;
713 ASSERT_TRUE(SUCCEEDED(shell->QueryInterface( 714 ASSERT_TRUE(SUCCEEDED(shell->QueryInterface(
714 IID_IPersistFile, reinterpret_cast<LPVOID*>(&persist)))); 715 IID_IPersistFile, reinterpret_cast<LPVOID*>(&persist))));
715 EXPECT_TRUE(SUCCEEDED(shell->SetPath(app_path.value().c_str()))); 716 EXPECT_TRUE(SUCCEEDED(shell->SetPath(app_path.value().c_str())));
(...skipping 28 matching lines...) Expand all
744 std::string content(buffer.get(), read_size); 745 std::string content(buffer.get(), read_size);
745 CloseHandle(file); 746 CloseHandle(file);
746 747
747 EXPECT_TRUE(!r.is_pending()); 748 EXPECT_TRUE(!r.is_pending());
748 EXPECT_EQ(1, d.received_redirect_count()); 749 EXPECT_EQ(1, d.received_redirect_count());
749 EXPECT_EQ(content, d.data_received()); 750 EXPECT_EQ(content, d.data_received());
750 } 751 }
751 752
752 // Clean the shortcut 753 // Clean the shortcut
753 DeleteFile(lnk_path.c_str()); 754 DeleteFile(lnk_path.c_str());
754 CoUninitialize();
755 } 755 }
756 #endif // defined(OS_WIN) 756 #endif // defined(OS_WIN)
757 757
758 TEST_F(URLRequestTest, FileDirCancelTest) { 758 TEST_F(URLRequestTest, FileDirCancelTest) {
759 // Put in mock resource provider. 759 // Put in mock resource provider.
760 NetModule::SetResourceProvider(TestNetResourceProvider); 760 NetModule::SetResourceProvider(TestNetResourceProvider);
761 761
762 TestDelegate d; 762 TestDelegate d;
763 { 763 {
764 FilePath file_path; 764 FilePath file_path;
(...skipping 4068 matching lines...) Expand 10 before | Expand all | Expand 10 after
4833 4833
4834 EXPECT_FALSE(r.is_pending()); 4834 EXPECT_FALSE(r.is_pending());
4835 EXPECT_EQ(1, d->response_started_count()); 4835 EXPECT_EQ(1, d->response_started_count());
4836 EXPECT_FALSE(d->received_data_before_response()); 4836 EXPECT_FALSE(d->received_data_before_response());
4837 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size)); 4837 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size));
4838 } 4838 }
4839 } 4839 }
4840 #endif // !defined(DISABLE_FTP_SUPPORT) 4840 #endif // !defined(DISABLE_FTP_SUPPORT)
4841 4841
4842 } // namespace net 4842 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698