|
7 | 7 | #include "tests\RA_UnitTestHelpers.h" |
8 | 8 | #include "tests\mocks\MockEmulatorContext.hh" |
9 | 9 | #include "tests\mocks\MockGameContext.hh" |
| 10 | +#include "tests\mocks\MockConsoleContext.hh" |
10 | 11 | #include "tests\mocks\MockWindowManager.hh" |
11 | 12 |
|
12 | 13 | #undef GetMessage |
@@ -1918,8 +1919,66 @@ TEST_CLASS(MemoryViewerViewModel_Tests) |
1918 | 1919 | Assert::IsTrue(viewer.NeedsRedraw()); |
1919 | 1920 | viewer.MockRender(); |
1920 | 1921 | } |
| 1922 | + |
| 1923 | + TEST_METHOD(TestOnShiftClickEightBit) |
| 1924 | + { |
| 1925 | + ra::data::context::mocks::MockConsoleContext mockConsole(PlayStation, L"Playstation"); |
| 1926 | + |
| 1927 | + MemoryViewerViewModelHarness viewer; |
| 1928 | + viewer.InitializeMemory(128); // 8 rows of 16 bytes |
| 1929 | + viewer.mockEmulatorContext.WriteMemoryByte(0U, 0x20); |
| 1930 | + viewer.mockEmulatorContext.WriteMemoryByte(1U, 0xff); |
| 1931 | + viewer.mockEmulatorContext.WriteMemoryByte(2U, 0x0); |
| 1932 | + |
| 1933 | + Assert::AreEqual(MemSize::EightBit, viewer.GetSize()); |
| 1934 | + Assert::AreEqual({ 0U }, viewer.GetAddress()); |
| 1935 | + Assert::AreEqual({ 0U }, viewer.GetSelectedNibble()); |
| 1936 | + |
| 1937 | + // Shift click on the first byte containing 0x20 should lead to address 0x20 |
| 1938 | + viewer.OnShiftClick(10 * CHAR_WIDTH, CHAR_HEIGHT + 4); |
| 1939 | + Assert::AreEqual({ 0x20U }, viewer.GetAddress()); |
| 1940 | + |
| 1941 | + // Shift click on the second byte containing 0xFF should lead to address 0x7F as 0xFF is bigger than the last |
| 1942 | + // address in memory |
| 1943 | + viewer.OnShiftClick(13 * CHAR_WIDTH, CHAR_HEIGHT + 4); |
| 1944 | + Assert::AreEqual({0x7FU}, viewer.GetAddress()); |
| 1945 | + |
| 1946 | + // Shift click on the third byte containing 0x0 should lead back to address 0x0 |
| 1947 | + viewer.OnShiftClick(16 * CHAR_WIDTH, CHAR_HEIGHT + 4); |
| 1948 | + Assert::AreEqual({0x0U}, viewer.GetAddress()); |
| 1949 | + } |
| 1950 | + |
| 1951 | + TEST_METHOD(TestOnShiftClickSixTeenBit) |
| 1952 | + { |
| 1953 | + ra::data::context::mocks::MockConsoleContext mockConsole(PlayStation, L"Playstation"); |
| 1954 | + |
| 1955 | + MemoryViewerViewModelHarness viewer; |
| 1956 | + viewer.InitializeMemory(512); // 32 rows of 16 bytes |
| 1957 | + viewer.SetSize(MemSize::SixteenBit); |
| 1958 | + viewer.mockEmulatorContext.WriteMemory(0U, MemSize::SixteenBit, 0x20); |
| 1959 | + viewer.mockEmulatorContext.WriteMemory(2U, MemSize::SixteenBit, 0xff); |
| 1960 | + viewer.mockEmulatorContext.WriteMemory(4U, MemSize::SixteenBit, 0xffff); |
| 1961 | + |
| 1962 | + Assert::AreEqual(MemSize::SixteenBit, viewer.GetSize()); |
| 1963 | + Assert::AreEqual({0U}, viewer.GetAddress()); |
| 1964 | + Assert::AreEqual({0U}, viewer.GetSelectedNibble()); |
| 1965 | + |
| 1966 | + // Shift click on the first word containing 0x20 should lead to address 0x20 |
| 1967 | + viewer.OnShiftClick(10 * CHAR_WIDTH, CHAR_HEIGHT + 4); |
| 1968 | + Assert::AreEqual({0x20U}, viewer.GetAddress()); |
| 1969 | + |
| 1970 | + // Shift click on the second word containing 0x40 should lead to address 0xFF |
| 1971 | + viewer.OnShiftClick(15 * CHAR_WIDTH, CHAR_HEIGHT + 4); |
| 1972 | + Assert::AreEqual({0xFFU}, viewer.GetAddress()); |
| 1973 | + |
| 1974 | + // Shift click on the third word containing 0xFFFF should lead to address 0x1FF as 0xFFFF is bigger than the |
| 1975 | + // last address in memory |
| 1976 | + viewer.OnShiftClick(19 * CHAR_WIDTH, CHAR_HEIGHT + 4); |
| 1977 | + Assert::AreEqual({0x1FFU}, viewer.GetAddress()); |
| 1978 | + } |
1921 | 1979 | }; |
1922 | 1980 |
|
| 1981 | + |
1923 | 1982 | } // namespace tests |
1924 | 1983 | } // namespace viewmodels |
1925 | 1984 | } // namespace ui |
|
0 commit comments