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

Side by Side Diff: chrome/installer/setup/setup_util_unittest.cc

Issue 606473002: Remove implicit HANDLE conversions from chrome. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove spurious file and fix indent (+rebase) Created 6 years, 3 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 | « chrome/installer/setup/setup_util.cc ('k') | chrome/installer/setup/uninstall.cc » ('j') | 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) 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 "chrome/installer/setup/setup_util_unittest.h" 5 #include "chrome/installer/setup/setup_util_unittest.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 if (!::OpenProcessToken(::GetCurrentProcess(), TOKEN_QUERY, 59 if (!::OpenProcessToken(::GetCurrentProcess(), TOKEN_QUERY,
60 &temp_handle)) { 60 &temp_handle)) {
61 ADD_FAILURE(); 61 ADD_FAILURE();
62 return false; 62 return false;
63 } 63 }
64 64
65 base::win::ScopedHandle token(temp_handle); 65 base::win::ScopedHandle token(temp_handle);
66 66
67 // First get the size of the buffer needed for |privileges| below. 67 // First get the size of the buffer needed for |privileges| below.
68 DWORD size; 68 DWORD size;
69 EXPECT_FALSE(::GetTokenInformation(token, TokenPrivileges, NULL, 0, &size)); 69 EXPECT_FALSE(::GetTokenInformation(token.Get(), TokenPrivileges, NULL, 0,
70 &size));
70 71
71 scoped_ptr<BYTE[]> privileges_bytes(new BYTE[size]); 72 scoped_ptr<BYTE[]> privileges_bytes(new BYTE[size]);
72 TOKEN_PRIVILEGES* privileges = 73 TOKEN_PRIVILEGES* privileges =
73 reinterpret_cast<TOKEN_PRIVILEGES*>(privileges_bytes.get()); 74 reinterpret_cast<TOKEN_PRIVILEGES*>(privileges_bytes.get());
74 75
75 if (!::GetTokenInformation(token, TokenPrivileges, privileges, size, &size)) { 76 if (!::GetTokenInformation(token.Get(), TokenPrivileges, privileges, size,
77 &size)) {
76 ADD_FAILURE(); 78 ADD_FAILURE();
77 return false; 79 return false;
78 } 80 }
79 81
80 // There is no point getting a buffer to store more than |privilege_name|\0 as 82 // There is no point getting a buffer to store more than |privilege_name|\0 as
81 // anything longer will obviously not be equal to |privilege_name|. 83 // anything longer will obviously not be equal to |privilege_name|.
82 const DWORD desired_size = wcslen(privilege_name); 84 const DWORD desired_size = wcslen(privilege_name);
83 const DWORD buffer_size = desired_size + 1; 85 const DWORD buffer_size = desired_size + 1;
84 scoped_ptr<wchar_t[]> name_buffer(new wchar_t[buffer_size]); 86 scoped_ptr<wchar_t[]> name_buffer(new wchar_t[buffer_size]);
85 for (int i = privileges->PrivilegeCount - 1; i >= 0 ; --i) { 87 for (int i = privileges->PrivilegeCount - 1; i >= 0 ; --i) {
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 } 488 }
487 489
488 TEST(SetupUtilTest, ContainsUnsupportedSwitch) { 490 TEST(SetupUtilTest, ContainsUnsupportedSwitch) {
489 EXPECT_FALSE(installer::ContainsUnsupportedSwitch( 491 EXPECT_FALSE(installer::ContainsUnsupportedSwitch(
490 CommandLine::FromString(L"foo.exe"))); 492 CommandLine::FromString(L"foo.exe")));
491 EXPECT_FALSE(installer::ContainsUnsupportedSwitch( 493 EXPECT_FALSE(installer::ContainsUnsupportedSwitch(
492 CommandLine::FromString(L"foo.exe --multi-install --chrome"))); 494 CommandLine::FromString(L"foo.exe --multi-install --chrome")));
493 EXPECT_TRUE(installer::ContainsUnsupportedSwitch( 495 EXPECT_TRUE(installer::ContainsUnsupportedSwitch(
494 CommandLine::FromString(L"foo.exe --chrome-frame"))); 496 CommandLine::FromString(L"foo.exe --chrome-frame")));
495 } 497 }
OLDNEW
« no previous file with comments | « chrome/installer/setup/setup_util.cc ('k') | chrome/installer/setup/uninstall.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698