OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 // |
| 5 // Unit tests for the CEEE utilities. |
| 6 |
| 7 #include "ceee/ie/common/ceee_util.h" |
| 8 |
| 9 #include <ostream> // NOLINT |
| 10 #include <winerror.h> |
| 11 |
| 12 #include "base/logging.h" |
| 13 #include "gmock/gmock.h" |
| 14 #include "gtest/gtest.h" |
| 15 #include "ceee/testing/utils/mock_static.h" |
| 16 |
| 17 namespace { |
| 18 |
| 19 using testing::_; |
| 20 using testing::Return; |
| 21 |
| 22 TEST(CeeeUtilTest, IsIeCeeeRegisteredRealRegistry) { |
| 23 // This exercises the code but does not assert on the result, |
| 24 // it simply prints the result for human evaluation. |
| 25 // |
| 26 // It's hard to mock the HKCR registry so don't try for now; |
| 27 // further tests mock out the entire registry access. |
| 28 bool is_registered = ceee_util::IsIeCeeeRegistered(); |
| 29 std::cout << "IsIeCeeeRegistered returned " << is_registered << std::endl; |
| 30 } |
| 31 |
| 32 MOCK_STATIC_CLASS_BEGIN(MockRegOpenKeyEx) |
| 33 MOCK_STATIC_INIT_BEGIN(MockRegOpenKeyEx) |
| 34 MOCK_STATIC_INIT(RegOpenKeyEx); |
| 35 MOCK_STATIC_INIT_END() |
| 36 |
| 37 MOCK_STATIC5(LSTATUS, APIENTRY, RegOpenKeyEx, |
| 38 HKEY, LPCWSTR, DWORD, REGSAM, PHKEY); |
| 39 MOCK_STATIC_CLASS_END(MockRegOpenKeyEx) |
| 40 |
| 41 TEST(CeeeUtilTest, IsIeCeeeRegisteredYes) { |
| 42 MockRegOpenKeyEx mock_reg; |
| 43 EXPECT_CALL(mock_reg, RegOpenKeyEx(_, _, _, _, _)) |
| 44 .WillOnce(Return(ERROR_SUCCESS)); |
| 45 ASSERT_TRUE(ceee_util::IsIeCeeeRegistered()); |
| 46 } |
| 47 |
| 48 TEST(CeeeUtilTest, IsIeCeeeRegisteredNo) { |
| 49 MockRegOpenKeyEx mock_reg; |
| 50 EXPECT_CALL(mock_reg, RegOpenKeyEx(_, _, _, _, _)) |
| 51 .WillOnce(Return(ERROR_FILE_NOT_FOUND)); |
| 52 ASSERT_FALSE(ceee_util::IsIeCeeeRegistered()); |
| 53 } |
| 54 |
| 55 } // namespace |
OLD | NEW |