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

Side by Side Diff: chrome/installer/util/self_cleaning_temp_dir_unittest.cc

Issue 1548153002: Switch to standard integer types in chrome/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <windows.h> 5 #include <windows.h>
6 #include <stdint.h>
6 #include <wincrypt.h> 7 #include <wincrypt.h>
7 8
8 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
9 #include "base/files/scoped_temp_dir.h" 10 #include "base/files/scoped_temp_dir.h"
11 #include "base/macros.h"
10 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
11 #include "chrome/installer/util/self_cleaning_temp_dir.h" 13 #include "chrome/installer/util/self_cleaning_temp_dir.h"
12 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
13 15
14 namespace { 16 namespace {
15 17
16 // Returns a string of 8 characters consisting of the letter 'R' followed by 18 // Returns a string of 8 characters consisting of the letter 'R' followed by
17 // seven random hex digits. 19 // seven random hex digits.
18 std::string GetRandomFilename() { 20 std::string GetRandomFilename() {
19 uint8 data[4]; 21 uint8_t data[4];
20 HCRYPTPROV crypt_ctx = NULL; 22 HCRYPTPROV crypt_ctx = NULL;
21 23
22 // Get four bytes of randomness. Use CAPI rather than the CRT since I've 24 // Get four bytes of randomness. Use CAPI rather than the CRT since I've
23 // seen the latter trivially repeat. 25 // seen the latter trivially repeat.
24 EXPECT_NE(FALSE, CryptAcquireContext(&crypt_ctx, NULL, NULL, PROV_RSA_FULL, 26 EXPECT_NE(FALSE, CryptAcquireContext(&crypt_ctx, NULL, NULL, PROV_RSA_FULL,
25 CRYPT_VERIFYCONTEXT)); 27 CRYPT_VERIFYCONTEXT));
26 EXPECT_NE(FALSE, CryptGenRandom(crypt_ctx, arraysize(data), &data[0])); 28 EXPECT_NE(FALSE, CryptGenRandom(crypt_ctx, arraysize(data), &data[0]));
27 EXPECT_NE(FALSE, CryptReleaseContext(crypt_ctx, 0)); 29 EXPECT_NE(FALSE, CryptReleaseContext(crypt_ctx, 0));
28 30
29 // Hexify the value. 31 // Hexify the value.
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 base::WriteFile(parent_temp_dir.AppendASCII(GetRandomFilename()), 165 base::WriteFile(parent_temp_dir.AppendASCII(GetRandomFilename()),
164 kHiHon, arraysize(kHiHon) - 1)); 166 kHiHon, arraysize(kHiHon) - 1));
165 } 167 }
166 EXPECT_FALSE(base::DirectoryExists(parent_temp_dir.Append(L"Three"))); 168 EXPECT_FALSE(base::DirectoryExists(parent_temp_dir.Append(L"Three")));
167 EXPECT_TRUE(base::DirectoryExists(parent_temp_dir)); 169 EXPECT_TRUE(base::DirectoryExists(parent_temp_dir));
168 EXPECT_TRUE(work_dir.Delete()); 170 EXPECT_TRUE(work_dir.Delete());
169 EXPECT_FALSE(base::DirectoryExists(parent_temp_dir.DirName().DirName())); 171 EXPECT_FALSE(base::DirectoryExists(parent_temp_dir.DirName().DirName()));
170 } 172 }
171 173
172 } // namespace installer 174 } // namespace installer
OLDNEW
« no previous file with comments | « chrome/installer/util/self_cleaning_temp_dir.h ('k') | chrome/installer/util/set_reg_value_work_item.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698