Changeset View
Changeset View
Standalone View
Standalone View
autotests/documenttest.cpp
Show First 20 Lines • Show All 67 Lines • ▼ Show 20 Line(s) | 39 | { | |||
---|---|---|---|---|---|
68 | delete dummyDocumentObserver; | 68 | delete dummyDocumentObserver; | ||
69 | } | 69 | } | ||
70 | 70 | | |||
71 | // Test that, if there's a XML file in docdata referring to a document, we | 71 | // Test that, if there's a XML file in docdata referring to a document, we | ||
72 | // detect that it must be migrated, that it doesn't get wiped out if you close | 72 | // detect that it must be migrated, that it doesn't get wiped out if you close | ||
73 | // the document without migrating and that it does get wiped out after migrating | 73 | // the document without migrating and that it does get wiped out after migrating | ||
74 | void DocumentTest::testDocdataMigration() | 74 | void DocumentTest::testDocdataMigration() | ||
75 | { | 75 | { | ||
76 | Okular::SettingsCore::instance( "documenttest" ); | 76 | Okular::SettingsCore::instance( QStringLiteral("documenttest") ); | ||
77 | 77 | | |||
78 | const QUrl testFileUrl = QUrl::fromLocalFile(KDESRCDIR "data/file1.pdf"); | 78 | const QUrl testFileUrl = QUrl::fromLocalFile(KDESRCDIR "data/file1.pdf"); | ||
79 | const QString testFilePath = testFileUrl.toLocalFile(); | 79 | const QString testFilePath = testFileUrl.toLocalFile(); | ||
80 | const qint64 testFileSize = QFileInfo(testFilePath).size(); | 80 | const qint64 testFileSize = QFileInfo(testFilePath).size(); | ||
81 | 81 | | |||
82 | // Copy XML file to the docdata/ directory | 82 | // Copy XML file to the docdata/ directory | ||
83 | const QString docDataPath = Okular::DocumentPrivate::docDataFileName(testFileUrl, testFileSize); | 83 | const QString docDataPath = Okular::DocumentPrivate::docDataFileName(testFileUrl, testFileSize); | ||
84 | QFile::remove(docDataPath); | 84 | QFile::remove(docDataPath); | ||
Show All 16 Lines | |||||
101 | // Reopen the document and check that the annotation is still present | 101 | // Reopen the document and check that the annotation is still present | ||
102 | // (because we have not migrated) | 102 | // (because we have not migrated) | ||
103 | QCOMPARE( m_document->openDocument( testFilePath, testFileUrl, mime ), Okular::Document::OpenSuccess ); | 103 | QCOMPARE( m_document->openDocument( testFilePath, testFileUrl, mime ), Okular::Document::OpenSuccess ); | ||
104 | QCOMPARE( m_document->page( 0 )->annotations().size(), 1 ); | 104 | QCOMPARE( m_document->page( 0 )->annotations().size(), 1 ); | ||
105 | QCOMPARE( m_document->page( 0 )->annotations().first()->uniqueName(), QString("testannot") ); | 105 | QCOMPARE( m_document->page( 0 )->annotations().first()->uniqueName(), QString("testannot") ); | ||
106 | QCOMPARE( m_document->isDocdataMigrationNeeded(), true ); | 106 | QCOMPARE( m_document->isDocdataMigrationNeeded(), true ); | ||
107 | 107 | | |||
108 | // Do the migration | 108 | // Do the migration | ||
109 | QTemporaryFile migratedSaveFile( QString( "%1/okrXXXXXX.pdf" ).arg( QDir::tempPath() ) ); | 109 | QTemporaryFile migratedSaveFile( QStringLiteral( "%1/okrXXXXXX.pdf" ).arg( QDir::tempPath() ) ); | ||
110 | QVERIFY( migratedSaveFile.open() ); | 110 | QVERIFY( migratedSaveFile.open() ); | ||
111 | migratedSaveFile.close(); | 111 | migratedSaveFile.close(); | ||
112 | QVERIFY( m_document->saveChanges( migratedSaveFile.fileName() ) ); | 112 | QVERIFY( m_document->saveChanges( migratedSaveFile.fileName() ) ); | ||
113 | m_document->docdataMigrationDone(); | 113 | m_document->docdataMigrationDone(); | ||
114 | QCOMPARE( m_document->isDocdataMigrationNeeded(), false ); | 114 | QCOMPARE( m_document->isDocdataMigrationNeeded(), false ); | ||
115 | m_document->closeDocument(); | 115 | m_document->closeDocument(); | ||
116 | 116 | | |||
117 | // Now the docdata file should have no annotations, let's check | 117 | // Now the docdata file should have no annotations, let's check | ||
Show All 16 Lines |