| // Copyright 2020 The Chromium OS Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| #include "typecd/port_manager.h" |
| |
| #include <gmock/gmock.h> |
| #include <gtest/gtest.h> |
| |
| #include "typecd/mock_ec_util.h" |
| |
| using ::testing::_; |
| using ::testing::Return; |
| |
| namespace typecd { |
| |
| class PortManagerTest : public ::testing::Test {}; |
| |
| // Test the basic case where mode entry is not supported |
| // by the ECUtil implementation. |
| TEST_F(PortManagerTest, ModeEntryNotSupported) { |
| auto ec_util = std::make_unique<MockECUtil>(); |
| EXPECT_CALL(*ec_util, ModeEntrySupported()).WillOnce(Return(false)); |
| EXPECT_CALL(*ec_util, EnterMode(_, _)).Times(0); |
| EXPECT_CALL(*ec_util, ExitMode(_)).Times(0); |
| |
| auto port_manager = std::make_unique<PortManager>(); |
| port_manager->SetECUtil(ec_util.get()); |
| |
| // It doesn't matter that we haven't registered any ports, since the code |
| // should return before this is checked. |
| port_manager->RunModeEntry(0); |
| |
| // There is no explicit test here, just that the Mock expectations should be |
| // met. |
| } |
| |
| } // namespace typecd |