1 /* This file is part of the KDE project
2 Copyright (C) 2006 Michaƫl Larouche <michael.larouche@kdemail.net>
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License version 2 as published by the Free Software Foundation.
8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details.
13 You should have received a copy of the GNU Library General Public License
14 along with this library; see the file COPYING.LIB. If not, write to
15 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 Boston, MA 02110-1301, USA.
19 #include "fakehardwaretest.h"
22 #include <QtTest/QtTest>
23 #include <QtCore/QStringList>
26 #include <solid/ifaces/device.h>
27 #include <solid/ifaces/deviceinterface.h>
28 #include <solid/ifaces/processor.h>
31 #include "solid/backends/fakehw/fakemanager.h"
32 #include "solid/backends/fakehw/fakedevice.h"
34 QTEST_MAIN(FakeHardwareTest
)
36 void FakeHardwareTest::testFakeBackend()
38 Solid::Backends::Fake::FakeManager
*fakeManager
= new Solid::Backends::Fake::FakeManager(0, TEST_DATA
);
40 QVERIFY(!fakeManager
->allDevices().isEmpty());
41 QVERIFY(fakeManager
->createDevice("/org/kde/solid/fakehw/computer")!=0);
42 QVERIFY(fakeManager
->createDevice("/com/helloworld/troll/compiutor")==0);
44 Solid::Backends::Fake::FakeDevice
*device
= static_cast<Solid::Backends::Fake::FakeDevice
*>(fakeManager
->createDevice("/org/kde/solid/fakehw/acpi_CPU0"));
46 QCOMPARE(device
->udi(), QString("/org/kde/solid/fakehw/acpi_CPU0"));
47 QCOMPARE(device
->parentUdi(), QString("/org/kde/solid/fakehw/computer"));
48 QCOMPARE(device
->vendor(), QString("Acme Corporation"));
49 QCOMPARE(device
->product(), QString("Solid Processor #0"));
51 QCOMPARE(device
->property("number").toString(), QString("0"));
52 QVERIFY(device
->propertyExists("number"));
53 QVERIFY(!device
->propertyExists("youstfuqewerrernoob"));
55 QVERIFY(device
->queryDeviceInterface(Solid::DeviceInterface::Processor
));
57 QObject
*interface
= device
->createDeviceInterface(Solid::DeviceInterface::Processor
);
58 Solid::Ifaces::Processor
*processor
= qobject_cast
<Solid::Ifaces::Processor
*>(interface
);
60 QCOMPARE(processor
->number(), 0);
61 QCOMPARE(processor
->canChangeFrequency(), true);
62 QCOMPARE((int)processor
->maxSpeed(), 3200);
64 Solid::Processor::InstructionSets instructionsets
;
65 instructionsets
|= Solid::Processor::IntelMmx
;
66 instructionsets
|= Solid::Processor::IntelSse
;
67 QCOMPARE(processor
->instructionSets(), instructionsets
);
70 #include "fakehardwaretest.moc"