James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 1 | #include <HwmonTempSensor.hpp> |
| 2 | #include <dbus/connection.hpp> |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 3 | #include <fstream> |
James Feist | 582be09 | 2018-11-27 10:54:59 -0800 | [diff] [blame] | 4 | #include <nlohmann/json.hpp> |
| 5 | |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 6 | #include "gtest/gtest.h" |
| 7 | |
| 8 | TEST(HwmonTempSensor, TestTMP75) |
| 9 | { |
| 10 | boost::asio::io_service io; |
| 11 | auto system_bus = |
| 12 | std::make_shared<dbus::connection>(io, dbus::bus::session); |
| 13 | dbus::DbusObjectServer object_server(system_bus); |
| 14 | |
| 15 | std::vector<thresholds::Threshold> sensor_thresholds; |
| 16 | auto t = thresholds::Threshold(thresholds::Level::CRITICAL, |
| 17 | thresholds::Direction::LOW, 80); |
| 18 | sensor_thresholds.emplace_back(t); |
| 19 | |
| 20 | std::ofstream test_file("test0.txt"); |
| 21 | test_file << "28\n"; |
| 22 | test_file.close(); |
| 23 | auto filename = std::string("test0.txt"); |
| 24 | auto tempsensname = std::string("test sensor"); |
| 25 | HwmonTempSensor test(filename, object_server, io, tempsensname, |
| 26 | std::move(sensor_thresholds)); |
| 27 | |
| 28 | std::remove("test0.txt"); |
| 29 | } |
| 30 | |
| 31 | TEST(HwmonTempSensor, TestTMP421) |
| 32 | { |
| 33 | boost::asio::io_service io; |
| 34 | auto system_bus = |
| 35 | std::make_shared<dbus::connection>(io, dbus::bus::session); |
| 36 | dbus::DbusObjectServer object_server(system_bus); |
| 37 | |
| 38 | std::vector<thresholds::Threshold> sensor_thresholds; |
| 39 | auto t = thresholds::Threshold(thresholds::Level::WARNING, |
| 40 | thresholds::Direction::HIGH, 80); |
| 41 | sensor_thresholds.emplace_back(t); |
| 42 | |
| 43 | std::ofstream test_file("test1.txt"); |
| 44 | test_file << "28\n"; |
| 45 | test_file.close(); |
| 46 | auto filename = std::string("test1.txt"); |
| 47 | auto tempsensname = std::string("test sensor"); |
| 48 | HwmonTempSensor test(filename, object_server, io, tempsensname, |
| 49 | std::move(sensor_thresholds)); |
| 50 | |
| 51 | std::remove("test1.txt"); |
| 52 | } |