Merge pull request #26362 from ksooo/estuary-rework-pvr-info-dialog
[xbmc.git] / xbmc / utils / test / TestCPUInfo.cpp
bloba411e2cfccef47e93105a85aacb2f7c5327c27c0
1 /*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
9 #if defined(TARGET_WINDOWS)
10 # include <windows.h>
11 #endif
13 #include "ServiceBroker.h"
14 #include "settings/AdvancedSettings.h"
15 #include "settings/SettingsComponent.h"
16 #include "utils/CPUInfo.h"
17 #include "utils/Temperature.h"
18 #include "utils/XTimeUtils.h"
20 #include <gtest/gtest.h>
22 struct TestCPUInfo : public ::testing::Test
24 TestCPUInfo() { CServiceBroker::RegisterCPUInfo(CCPUInfo::GetCPUInfo()); }
26 ~TestCPUInfo() { CServiceBroker::UnregisterCPUInfo(); }
29 TEST_F(TestCPUInfo, GetUsedPercentage)
31 EXPECT_GE(CServiceBroker::GetCPUInfo()->GetUsedPercentage(), 0);
34 TEST_F(TestCPUInfo, GetCPUCount)
36 EXPECT_GT(CServiceBroker::GetCPUInfo()->GetCPUCount(), 0);
39 TEST_F(TestCPUInfo, GetCPUFrequency)
41 EXPECT_GE(CServiceBroker::GetCPUInfo()->GetCPUFrequency(), 0.f);
44 #if defined(TARGET_WINDOWS) or defined(TARGET_DARWIN_OSX)
45 TEST_F(TestCPUInfo, DISABLED_GetTemperature)
46 #else
47 TEST_F(TestCPUInfo, GetTemperature)
48 #endif
50 CServiceBroker::GetSettingsComponent()->GetAdvancedSettings()->m_cpuTempCmd = "echo '50 c'";
51 CTemperature t;
52 EXPECT_TRUE(CServiceBroker::GetCPUInfo()->GetTemperature(t));
53 EXPECT_TRUE(t.IsValid());
54 EXPECT_EQ(t.ToCelsius(), 50);
57 TEST_F(TestCPUInfo, CoreInfo)
59 ASSERT_TRUE(CServiceBroker::GetCPUInfo()->HasCoreId(0));
60 const CoreInfo c = CServiceBroker::GetCPUInfo()->GetCoreInfo(0);
61 EXPECT_TRUE(c.m_id == 0);
64 TEST_F(TestCPUInfo, GetCoresUsageString)
66 EXPECT_STRNE("", CServiceBroker::GetCPUInfo()->GetCoresUsageString().c_str());
69 TEST_F(TestCPUInfo, GetCPUFeatures)
71 unsigned int a = CServiceBroker::GetCPUInfo()->GetCPUFeatures();
72 (void)a;