File: fakehardwaretest.cpp

package info (click to toggle)
solid 5.78.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 5,100 kB
  • sloc: cpp: 21,549; xml: 464; lex: 111; yacc: 83; sh: 14; makefile: 5
file content (62 lines) | stat: -rw-r--r-- 2,336 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
    SPDX-FileCopyrightText: 2006 Michaƫl Larouche <michael.larouche@kdemail.net>

    SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#include "fakehardwaretest.h"

// Qt includes
#include <QTest>

// Solid includes
#include <solid/devices/ifaces/device.h>
#include <solid/devices/ifaces/deviceinterface.h>
#include <solid/devices/ifaces/processor.h>

// Local includes
#include "solid/devices/backends/fakehw/fakemanager.h"
#include "solid/devices/backends/fakehw/fakedevice.h"

QTEST_MAIN(FakeHardwareTest)

void FakeHardwareTest::testFakeBackend()
{
    Solid::Backends::Fake::FakeManager *fakeManager = new Solid::Backends::Fake::FakeManager(nullptr, TEST_DATA);

    QVERIFY(!fakeManager->allDevices().isEmpty());
    QObject *computer = fakeManager->createDevice("/org/kde/solid/fakehw/computer");
    QVERIFY(computer != nullptr);
    QVERIFY(fakeManager->createDevice("/com/helloworld/troll/compiutor") == nullptr);

    Solid::Backends::Fake::FakeDevice *device = static_cast<Solid::Backends::Fake::FakeDevice *>(fakeManager->createDevice("/org/kde/solid/fakehw/acpi_CPU0"));

    QCOMPARE(device->udi(), QString("/org/kde/solid/fakehw/acpi_CPU0"));
    QCOMPARE(device->parentUdi(), QString("/org/kde/solid/fakehw/computer"));
    QCOMPARE(device->vendor(), QString("Acme Corporation"));
    QCOMPARE(device->product(), QString("Solid Processor #0"));

    QCOMPARE(device->property("number").toString(), QString("0"));
    QVERIFY(device->propertyExists("number"));
    QVERIFY(!device->propertyExists("youstfuqewerrernoob"));

    QVERIFY(device->queryDeviceInterface(Solid::DeviceInterface::Processor));

    QObject *interface = device->createDeviceInterface(Solid::DeviceInterface::Processor);
    Solid::Ifaces::Processor *processor = qobject_cast<Solid::Ifaces::Processor *>(interface);

    QCOMPARE(processor->number(), 0);
    QCOMPARE(processor->canChangeFrequency(), true);
    QCOMPARE((int)processor->maxSpeed(), 3200);

    Solid::Processor::InstructionSets instructionsets;
    instructionsets |= Solid::Processor::IntelMmx;
    instructionsets |= Solid::Processor::IntelSse;
    QCOMPARE(processor->instructionSets(), instructionsets);

    delete processor;
    delete device;
    delete computer;
    delete fakeManager;
}

#include "moc_fakehardwaretest.cpp"