| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2003 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2003 The WebRTC Project Authors. All rights reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 // Unittest for registry access API | 11 // Unittest for registry access API |
| 12 | 12 |
| 13 #include "webrtc/base/arraysize.h" |
| 13 #include "webrtc/base/gunit.h" | 14 #include "webrtc/base/gunit.h" |
| 14 #include "webrtc/base/common.h" | 15 #include "webrtc/base/common.h" |
| 15 #include "webrtc/base/win32regkey.h" | 16 #include "webrtc/base/win32regkey.h" |
| 16 | 17 |
| 17 namespace rtc { | 18 namespace rtc { |
| 18 | 19 |
| 19 #ifndef EXPECT_SUCCEEDED | 20 #ifndef EXPECT_SUCCEEDED |
| 20 #define EXPECT_SUCCEEDED(x) EXPECT_TRUE(SUCCEEDED(x)) | 21 #define EXPECT_SUCCEEDED(x) EXPECT_TRUE(SUCCEEDED(x)) |
| 21 #endif | 22 #endif |
| 22 | 23 |
| (...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 557 sizeof(kInvalidMultiSZ))); | 558 sizeof(kInvalidMultiSZ))); |
| 558 EXPECT_SUCCEEDED(RegKey::GetValue(kFullRkey1, kValNameMultiStr, &result)); | 559 EXPECT_SUCCEEDED(RegKey::GetValue(kFullRkey1, kValNameMultiStr, &result)); |
| 559 EXPECT_EQ(result.size(), 1); | 560 EXPECT_EQ(result.size(), 1); |
| 560 EXPECT_STREQ(result[0].c_str(), L"678"); | 561 EXPECT_STREQ(result[0].c_str(), L"678"); |
| 561 | 562 |
| 562 // Run the following test only in dev machine | 563 // Run the following test only in dev machine |
| 563 // This is because the build machine might not have admin privilege | 564 // This is because the build machine might not have admin privilege |
| 564 #ifdef IS_PRIVATE_BUILD | 565 #ifdef IS_PRIVATE_BUILD |
| 565 // get a temp file name | 566 // get a temp file name |
| 566 wchar_t temp_path[MAX_PATH] = {0}; | 567 wchar_t temp_path[MAX_PATH] = {0}; |
| 567 EXPECT_LT(::GetTempPath(ARRAY_SIZE(temp_path), temp_path), | 568 EXPECT_LT(::GetTempPath(arraysize(temp_path), temp_path), |
| 568 static_cast<DWORD>(ARRAY_SIZE(temp_path))); | 569 static_cast<DWORD>(arraysize(temp_path))); |
| 569 wchar_t temp_file[MAX_PATH] = {0}; | 570 wchar_t temp_file[MAX_PATH] = {0}; |
| 570 EXPECT_NE(::GetTempFileName(temp_path, L"rkut_", | 571 EXPECT_NE(::GetTempFileName(temp_path, L"rkut_", |
| 571 ::GetTickCount(), temp_file), 0); | 572 ::GetTickCount(), temp_file), 0); |
| 572 | 573 |
| 573 // test save | 574 // test save |
| 574 EXPECT_SUCCEEDED(RegKey::SetValue(kFullRkey1Subkey, kValNameInt, kIntVal)); | 575 EXPECT_SUCCEEDED(RegKey::SetValue(kFullRkey1Subkey, kValNameInt, kIntVal)); |
| 575 EXPECT_SUCCEEDED(RegKey::SetValue(kFullRkey1Subkey, kValNameInt64, kIntVal64))
; | 576 EXPECT_SUCCEEDED(RegKey::SetValue(kFullRkey1Subkey, kValNameInt64, kIntVal64))
; |
| 576 EXPECT_SUCCEEDED(RegKey::Save(kFullRkey1Subkey, temp_file)); | 577 EXPECT_SUCCEEDED(RegKey::Save(kFullRkey1Subkey, temp_file)); |
| 577 EXPECT_SUCCEEDED(RegKey::DeleteValue(kFullRkey1Subkey, kValNameInt)); | 578 EXPECT_SUCCEEDED(RegKey::DeleteValue(kFullRkey1Subkey, kValNameInt)); |
| 578 EXPECT_SUCCEEDED(RegKey::DeleteValue(kFullRkey1Subkey, kValNameInt64)); | 579 EXPECT_SUCCEEDED(RegKey::DeleteValue(kFullRkey1Subkey, kValNameInt64)); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 597 } | 598 } |
| 598 | 599 |
| 599 // Run both tests under the same test target. Because they access (read and | 600 // Run both tests under the same test target. Because they access (read and |
| 600 // write) the same registry keys they can't run in parallel with eachother. | 601 // write) the same registry keys they can't run in parallel with eachother. |
| 601 TEST(RegKeyTest, RegKeyFunctionsTest) { | 602 TEST(RegKeyTest, RegKeyFunctionsTest) { |
| 602 RegKeyNonStaticFunctionsTest(); | 603 RegKeyNonStaticFunctionsTest(); |
| 603 RegKeyStaticFunctionsTest(); | 604 RegKeyStaticFunctionsTest(); |
| 604 } | 605 } |
| 605 | 606 |
| 606 } // namespace rtc | 607 } // namespace rtc |
| OLD | NEW |