refact: DesktopFile's method and structure

Signed-off-by: ComixHe <heyuming@deepin.org>
This commit is contained in:
ComixHe
2023-08-21 16:02:26 +08:00
committed by Comix
parent 65b6c9eaf0
commit 06ee5e5899
10 changed files with 155 additions and 99 deletions

View File

@ -32,8 +32,8 @@ public:
bus.setDestBus();
m_am = new ApplicationManager1Service{std::make_unique<CGroupsIdentifier>(), bus.globalServerBus()};
DesktopFile file{true, "/usr/share/applications/test-Application.desktop", "test-Application", 0};
auto ptr = std::make_unique<QFile>(QString{"/usr/share/applications/test-Application.desktop"});
DesktopFile file{std::move(ptr), "test-Application", 0};
QSharedPointer<ApplicationService> app = QSharedPointer<ApplicationService>::create(std::move(file), nullptr);
QSharedPointer<InstanceService> instance =
QSharedPointer<InstanceService>::create(InstancePath.path().split('/').last(), ApplicationPath.path(), QString{"/"});

View File

@ -45,7 +45,7 @@ TEST_F(TestDesktopEntry, desktopFile)
auto curDir = QDir::current();
QString path{curDir.absolutePath() + QDir::separator() + "data" + QDir::separator() + "applications" + QDir::separator() +
"deepin-editor.desktop"};
EXPECT_EQ(exampleFile->fileSource().toStdString(), path.toStdString());
EXPECT_EQ(exampleFile->sourcePath(), path);
EXPECT_EQ(exampleFile->desktopId().toStdString(), "deepin-editor");
}
@ -54,7 +54,7 @@ TEST_F(TestDesktopEntry, prase)
const auto &exampleFile = file();
ASSERT_FALSE(exampleFile.isNull());
DesktopEntry entry;
QFile in{exampleFile->fileSource()};
QFile in{exampleFile->sourcePath()};
ASSERT_TRUE(in.open(QFile::ExistingOnly | QFile::ReadOnly | QFile::Text));
QTextStream fs{&in};
auto err = entry.parse(fs);