File indexing completed on 2024-10-13 03:42:25
0001 /* 0002 SPDX-FileCopyrightText: 2006 Michaƫl Larouche <michael.larouche@kdemail.net> 0003 0004 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0005 */ 0006 #include "fakehardwaretest.h" 0007 0008 // Qt includes 0009 #include <QTest> 0010 0011 // Solid includes 0012 #include <solid/devices/ifaces/device.h> 0013 #include <solid/devices/ifaces/deviceinterface.h> 0014 #include <solid/devices/ifaces/processor.h> 0015 0016 // Local includes 0017 #include "solid/devices/backends/fakehw/fakedevice.h" 0018 #include "solid/devices/backends/fakehw/fakemanager.h" 0019 0020 QTEST_MAIN(FakeHardwareTest) 0021 0022 void FakeHardwareTest::testFakeBackend() 0023 { 0024 Solid::Backends::Fake::FakeManager *fakeManager = new Solid::Backends::Fake::FakeManager(nullptr, TEST_DATA); 0025 0026 QVERIFY(!fakeManager->allDevices().isEmpty()); 0027 QObject *computer = fakeManager->createDevice("/org/kde/solid/fakehw/computer"); 0028 QVERIFY(computer != nullptr); 0029 QVERIFY(fakeManager->createDevice("/com/helloworld/troll/compiutor") == nullptr); 0030 0031 Solid::Backends::Fake::FakeDevice *device = static_cast<Solid::Backends::Fake::FakeDevice *>(fakeManager->createDevice("/org/kde/solid/fakehw/acpi_CPU0")); 0032 0033 QCOMPARE(device->udi(), QString("/org/kde/solid/fakehw/acpi_CPU0")); 0034 QCOMPARE(device->parentUdi(), QString("/org/kde/solid/fakehw/computer")); 0035 QCOMPARE(device->vendor(), QString("Acme Corporation")); 0036 QCOMPARE(device->product(), QString("Solid Processor #0")); 0037 0038 QCOMPARE(device->property("number").toString(), QString("0")); 0039 QVERIFY(device->propertyExists("number")); 0040 QVERIFY(!device->propertyExists("youstfuqewerrernoob")); 0041 0042 QVERIFY(device->queryDeviceInterface(Solid::DeviceInterface::Processor)); 0043 0044 QObject *interface = device->createDeviceInterface(Solid::DeviceInterface::Processor); 0045 Solid::Ifaces::Processor *processor = qobject_cast<Solid::Ifaces::Processor *>(interface); 0046 0047 QCOMPARE(processor->number(), 0); 0048 QCOMPARE(processor->canChangeFrequency(), true); 0049 QCOMPARE((int)processor->maxSpeed(), 3200); 0050 0051 Solid::Processor::InstructionSets instructionsets; 0052 instructionsets |= Solid::Processor::IntelMmx; 0053 instructionsets |= Solid::Processor::IntelSse; 0054 QCOMPARE(processor->instructionSets(), instructionsets); 0055 0056 delete processor; 0057 delete device; 0058 delete computer; 0059 delete fakeManager; 0060 } 0061 0062 #include "moc_fakehardwaretest.cpp"