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

Side by Side Diff: net/winhttp_adapter_unittest.cc

Issue 624713003: Keep only base/extractor.[cc|h]. (Closed) Base URL: https://chromium.googlesource.com/external/omaha.git@master
Patch Set: Created 6 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
« no previous file with comments | « net/winhttp_adapter.cc ('k') | net/winhttp_vtable.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2010 Google Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 // ========================================================================
15
16 #include <windows.h>
17 #include "base/scoped_ptr.h"
18 #include "omaha/net/winhttp_adapter.h"
19 #include "omaha/testing/unit_test.h"
20
21 namespace omaha {
22
23 // Tests null WinHttp handles are allowed for WinHttp calls. WinHttp may or
24 // may have not been initialized up to this point. This affects the return
25 // value of some of the calls below.
26 TEST(WinHttpAdapter, NullHandles) {
27 WinHttpAdapter winhttp_adapter;
28 EXPECT_HRESULT_SUCCEEDED(winhttp_adapter.Initialize());
29
30 // Null session handle.
31 HRESULT hr = winhttp_adapter.Connect(NULL, _T("127.0.0.1"), 80);
32 EXPECT_TRUE(hr == HRESULT_FROM_WIN32(ERROR_WINHTTP_NOT_INITIALIZED) ||
33 hr == HRESULT_FROM_WIN32(ERROR_INVALID_HANDLE));
34
35 // Opens a session, connects, closes the connection handle, and then
36 // tries to open a request for the null connection.
37 scoped_ptr<HttpClient> http_client(CreateHttpClient());
38 EXPECT_HRESULT_SUCCEEDED(http_client->Initialize());
39
40 HINTERNET session_handle = NULL;
41 EXPECT_HRESULT_SUCCEEDED(http_client->Open(NULL,
42 WINHTTP_ACCESS_TYPE_NO_PROXY,
43 WINHTTP_NO_PROXY_NAME,
44 WINHTTP_NO_PROXY_BYPASS,
45 0, // Synchronous mode.
46 &session_handle));
47 EXPECT_NE(static_cast<HINTERNET>(NULL), session_handle);
48 EXPECT_HRESULT_SUCCEEDED(winhttp_adapter.Connect(session_handle,
49 _T("127.0.0.1"),
50 80));
51 winhttp_adapter.CloseHandles();
52 EXPECT_EQ(HRESULT_FROM_WIN32(ERROR_INVALID_HANDLE),
53 winhttp_adapter.OpenRequest(NULL, // verb
54 NULL, // uri,
55 NULL, // version
56 NULL, // referrer
57 NULL, // accept_types
58 0)); // flags
59
60 // Null request handle.
61 EXPECT_EQ(HRESULT_FROM_WIN32(ERROR_INVALID_HANDLE),
62 winhttp_adapter.QueryDataAvailable(NULL));
63 }
64
65 } // namespace omaha
OLDNEW
« no previous file with comments | « net/winhttp_adapter.cc ('k') | net/winhttp_vtable.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698