|
11 | 11 | #include "runtime/os_interface/windows/os_interface.h" |
12 | 12 | #include "runtime/memory_manager/os_agnostic_memory_manager.h" |
13 | 13 | #include "runtime/helpers/options.h" |
| 14 | +#include "unit_tests/libult/create_command_stream.h" |
14 | 15 | #include "unit_tests/mocks/mock_device.h" |
15 | 16 | #include "unit_tests/mocks/mock_csr.h" |
16 | 17 | #include "unit_tests/mocks/mock_wddm.h" |
17 | | -#include "unit_tests/libult/create_command_stream.h" |
| 18 | +#include "unit_tests/os_interface/windows/registry_reader_tests.h" |
18 | 19 | #include "gtest/gtest.h" |
| 20 | +#include <memory> |
19 | 21 |
|
20 | 22 | namespace OCLRT { |
21 | 23 |
|
@@ -107,5 +109,52 @@ TEST(DriverInfo, GivenDriverInfoWhenThenReturnNonNullptr) { |
107 | 109 |
|
108 | 110 | EXPECT_STREQ(defaultVersion.c_str(), driverVersion.c_str()); |
109 | 111 | EXPECT_TRUE(registryReaderMock->properVersionKey); |
110 | | -} |
| 112 | +}; |
| 113 | + |
| 114 | +TEST(DriverInfo, givenInitializedOsInterfaceWhenCreateDriverInfoThenReturnDriverInfoWindowsNotNullptr) { |
| 115 | + |
| 116 | + std::unique_ptr<OSInterface> osInterface(new OSInterface()); |
| 117 | + osInterface->get()->setWddm(Wddm::createWddm()); |
| 118 | + EXPECT_NE(nullptr, osInterface->get()->getWddm()); |
| 119 | + |
| 120 | + std::unique_ptr<DriverInfo> driverInfo(DriverInfo::create(osInterface.get())); |
| 121 | + |
| 122 | + EXPECT_NE(nullptr, driverInfo); |
| 123 | +}; |
| 124 | + |
| 125 | +TEST(DriverInfo, givenNotInitializedOsInterfaceWhenCreateDriverInfoThenReturnDriverInfoWindowsNullptr) { |
| 126 | + |
| 127 | + std::unique_ptr<OSInterface> osInterface; |
| 128 | + |
| 129 | + std::unique_ptr<DriverInfo> driverInfo(DriverInfo::create(osInterface.get())); |
| 130 | + |
| 131 | + EXPECT_EQ(nullptr, driverInfo); |
| 132 | +}; |
| 133 | + |
| 134 | +class MockDriverInfoWindows : public DriverInfoWindows { |
| 135 | + |
| 136 | + public: |
| 137 | + const char *getRegistryReaderRegKey() { |
| 138 | + return reader->getRegKey(); |
| 139 | + } |
| 140 | + TestedRegistryReader *reader; |
| 141 | + |
| 142 | + static MockDriverInfoWindows *create(std::string path) { |
| 143 | + |
| 144 | + auto result = new MockDriverInfoWindows(); |
| 145 | + result->reader = new TestedRegistryReader(path); |
| 146 | + result->setRegistryReader(result->reader); |
| 147 | + |
| 148 | + return result; |
| 149 | + }; |
| 150 | +}; |
| 151 | + |
| 152 | +TEST(DriverInfo, givenInitializedOsInterfaceWhenCreateDriverInfoWindowsThenSetRegistryReaderWithExpectRegKey) { |
| 153 | + std::string path = ""; |
| 154 | + std::unique_ptr<MockDriverInfoWindows> driverInfo(MockDriverInfoWindows::create(path)); |
| 155 | + std::unique_ptr<TestedRegistryReader> reader(new TestedRegistryReader(path)); |
| 156 | + EXPECT_NE(nullptr, reader); |
| 157 | + EXPECT_STREQ(driverInfo->getRegistryReaderRegKey(), reader->getRegKey()); |
| 158 | +}; |
| 159 | + |
111 | 160 | } // namespace OCLRT |
0 commit comments