psu-ng: Add code to set ON_OFF_CONFIG

Add code that sends the appropriate ON_OFF_CONFIG mask for the power
supply power on operation.

Tested:
    Ran gtest using x86sdk
    Used simulator to change ON_OFF_CONFIG value, restarted service,
    verified ON_OFF_CONFIG changed.
    Used i2cget on hardware to change ON_OFF_CONFIG, restarted service,
    verified ON_OFF_CONFIG changed.

Signed-off-by: Brandon Wyman <bjwyman@gmail.com>
Change-Id: Ifd9d63fcd2e86a62b7358e08958b5e2dbd21db9f
diff --git a/phosphor-power-supply/test/power_supply_tests.cpp b/phosphor-power-supply/test/power_supply_tests.cpp
index c6d4814..5eb4b3e 100644
--- a/phosphor-power-supply/test/power_supply_tests.cpp
+++ b/phosphor-power-supply/test/power_supply_tests.cpp
@@ -11,8 +11,11 @@
 using namespace phosphor::pmbus;
 
 using ::testing::_;
+using ::testing::Args;
 using ::testing::Assign;
 using ::testing::DoAll;
+using ::testing::ElementsAre;
+using ::testing::NotNull;
 using ::testing::Return;
 using ::testing::StrEq;
 
@@ -148,6 +151,46 @@
     // TODO: ReadFailure
 }
 
+TEST_F(PowerSupplyTests, OnOffConfig)
+{
+    auto bus = sdbusplus::bus::new_default();
+    uint8_t data = 0x15;
+
+    // Test where PSU is NOT present
+    try
+    {
+        EXPECT_CALL(mockedUtil, getPresence(_, StrEq(PSUInventoryPath)))
+            .Times(1)
+            .WillOnce(Return(false));
+        PowerSupply psu{bus, PSUInventoryPath, 4, "0069"};
+        MockedPMBus& mockPMBus = static_cast<MockedPMBus&>(psu.getPMBus());
+        // If it is not present, I should not be trying to write to it.
+        EXPECT_CALL(mockPMBus, writeBinary(_, _, _)).Times(0);
+        psu.onOffConfig(data);
+    }
+    catch (...)
+    {
+    }
+
+    // Test where PSU is present
+    try
+    {
+        EXPECT_CALL(mockedUtil, getPresence(_, StrEq(PSUInventoryPath)))
+            .Times(1)
+            .WillOnce(Return(true)); // present
+        PowerSupply psu{bus, PSUInventoryPath, 5, "006a"};
+        MockedPMBus& mockPMBus = static_cast<MockedPMBus&>(psu.getPMBus());
+        // TODO: ???should I check the filename?
+        EXPECT_CALL(mockPMBus,
+                    writeBinary(_, ElementsAre(0x15), Type::HwmonDeviceDebug))
+            .Times(1);
+        psu.onOffConfig(data);
+    }
+    catch (...)
+    {
+    }
+}
+
 TEST_F(PowerSupplyTests, ClearFaults)
 {
     auto bus = sdbusplus::bus::new_default();