tdf#87530 finish the regression test
Need to store the document twice to actually reproduce the bug. Change-Id: I2332bce1e30546b3a9fe2ec020f2eea8e8d0da58
This commit is contained in:
@@ -439,24 +439,61 @@ void SwMacrosTest::testFdo87530()
|
|||||||
Reference<css::lang::XComponent> xComponent =
|
Reference<css::lang::XComponent> xComponent =
|
||||||
loadFromDesktop("private:factory/swriter", "com.sun.star.text.TextDocument");
|
loadFromDesktop("private:factory/swriter", "com.sun.star.text.TextDocument");
|
||||||
|
|
||||||
|
utl::TempFile aTempFile;
|
||||||
|
aTempFile.EnableKillingFile();
|
||||||
|
|
||||||
|
Sequence<beans::PropertyValue> desc(1);
|
||||||
|
desc[0].Name = "FilterName";
|
||||||
|
desc[0].Value <<= OUString("writer8");
|
||||||
|
|
||||||
{
|
{
|
||||||
|
// insert initial password protected library
|
||||||
Reference<document::XEmbeddedScripts> xDocScr(xComponent, UNO_QUERY_THROW);
|
Reference<document::XEmbeddedScripts> xDocScr(xComponent, UNO_QUERY_THROW);
|
||||||
Reference<script::XStorageBasedLibraryContainer> xStorBasLib(xDocScr->getBasicLibraries());
|
Reference<script::XStorageBasedLibraryContainer> xStorBasLib(xDocScr->getBasicLibraries());
|
||||||
Reference<script::XLibraryContainer> xBasLib(xStorBasLib, UNO_QUERY_THROW);
|
Reference<script::XLibraryContainer> xBasLib(xStorBasLib, UNO_QUERY_THROW);
|
||||||
Reference<script::XLibraryContainerPassword> xBasLibPwd(xStorBasLib, UNO_QUERY_THROW);
|
Reference<script::XLibraryContainerPassword> xBasLibPwd(xStorBasLib, UNO_QUERY_THROW);
|
||||||
xBasLib->createLibrary("Library1");
|
Reference<container::XNameContainer> xLibrary(xBasLib->createLibrary("BarLibrary"));
|
||||||
xBasLibPwd->changeLibraryPassword("Library1", "", "foo");
|
xLibrary->insertByName("BarModule",
|
||||||
|
uno::makeAny(OUString("Sub Main\nEnd Sub\n")));
|
||||||
|
xBasLibPwd->changeLibraryPassword("BarLibrary", "", "foo");
|
||||||
|
|
||||||
|
Reference<frame::XStorable> xDocStorable(xComponent, UNO_QUERY_THROW);
|
||||||
|
CPPUNIT_ASSERT(xDocStorable.is());
|
||||||
|
|
||||||
|
xDocStorable->storeAsURL(aTempFile.GetURL(), desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
Reference<frame::XStorable> xDocStorable(xComponent, UNO_QUERY_THROW);
|
Reference<util::XCloseable>(xComponent, UNO_QUERY_THROW)->close(false);
|
||||||
CPPUNIT_ASSERT(xDocStorable.is());
|
|
||||||
|
|
||||||
utl::TempFile aTempFile;
|
// re-load
|
||||||
aTempFile.EnableKillingFile();
|
xComponent = loadFromDesktop(aTempFile.GetURL(), "com.sun.star.text.TextDocument");
|
||||||
Sequence<beans::PropertyValue> desc(1);
|
|
||||||
desc[0].Name = "FilterName";
|
{
|
||||||
desc[0].Value <<= OUString("writer8");
|
// check that password-protected library survived store and re-load
|
||||||
xDocStorable->storeAsURL(aTempFile.GetURL(), desc);
|
Reference<document::XEmbeddedScripts> xDocScr(xComponent, UNO_QUERY_THROW);
|
||||||
|
Reference<script::XStorageBasedLibraryContainer> xStorBasLib(xDocScr->getBasicLibraries());
|
||||||
|
Reference<script::XLibraryContainer> xBasLib(xStorBasLib, UNO_QUERY_THROW);
|
||||||
|
Reference<script::XLibraryContainerPassword> xBasLibPwd(xStorBasLib, UNO_QUERY_THROW);
|
||||||
|
CPPUNIT_ASSERT(xBasLibPwd->isLibraryPasswordProtected("BarLibrary"));
|
||||||
|
CPPUNIT_ASSERT(xBasLibPwd->verifyLibraryPassword("BarLibrary", "foo"));
|
||||||
|
xBasLib->loadLibrary("BarLibrary");
|
||||||
|
CPPUNIT_ASSERT(xBasLib->isLibraryLoaded("BarLibrary"));
|
||||||
|
Reference<container::XNameContainer> xLibrary(xBasLib->getByName("BarLibrary"), UNO_QUERY);
|
||||||
|
Any module(xLibrary->getByName("BarModule"));
|
||||||
|
CPPUNIT_ASSERT_EQUAL(module.get<OUString>(), OUString("Sub Main\nEnd Sub\n"));
|
||||||
|
|
||||||
|
// add a second module now - tdf#87530 happened here
|
||||||
|
Reference<container::XNameContainer> xFooLib(xBasLib->createLibrary("FooLibrary"));
|
||||||
|
xFooLib->insertByName("FooModule",
|
||||||
|
uno::makeAny(OUString("Sub Main\nEnd Sub\n")));
|
||||||
|
xBasLibPwd->changeLibraryPassword("FooLibrary", "", "foo");
|
||||||
|
|
||||||
|
// store again
|
||||||
|
Reference<frame::XStorable> xDocStorable(xComponent, UNO_QUERY_THROW);
|
||||||
|
CPPUNIT_ASSERT(xDocStorable.is());
|
||||||
|
|
||||||
|
xDocStorable->store();
|
||||||
|
}
|
||||||
|
|
||||||
Reference<util::XCloseable>(xComponent, UNO_QUERY_THROW)->close(false);
|
Reference<util::XCloseable>(xComponent, UNO_QUERY_THROW)->close(false);
|
||||||
|
|
||||||
@@ -468,14 +505,16 @@ void SwMacrosTest::testFdo87530()
|
|||||||
Reference<script::XStorageBasedLibraryContainer> xStorBasLib(xDocScr->getBasicLibraries());
|
Reference<script::XStorageBasedLibraryContainer> xStorBasLib(xDocScr->getBasicLibraries());
|
||||||
Reference<script::XLibraryContainer> xBasLib(xStorBasLib, UNO_QUERY_THROW);
|
Reference<script::XLibraryContainer> xBasLib(xStorBasLib, UNO_QUERY_THROW);
|
||||||
Reference<script::XLibraryContainerPassword> xBasLibPwd(xStorBasLib, UNO_QUERY_THROW);
|
Reference<script::XLibraryContainerPassword> xBasLibPwd(xStorBasLib, UNO_QUERY_THROW);
|
||||||
CPPUNIT_ASSERT(xBasLibPwd->isLibraryPasswordProtected("Library1"));
|
CPPUNIT_ASSERT(xBasLibPwd->isLibraryPasswordProtected("FooLibrary"));
|
||||||
CPPUNIT_ASSERT(xBasLibPwd->verifyLibraryPassword("Library1", "foo"));
|
CPPUNIT_ASSERT(xBasLibPwd->verifyLibraryPassword("FooLibrary", "foo"));
|
||||||
xBasLib->loadLibrary("Library1");
|
xBasLib->loadLibrary("FooLibrary");
|
||||||
CPPUNIT_ASSERT(xBasLib->isLibraryLoaded("Library1"));
|
CPPUNIT_ASSERT(xBasLib->isLibraryLoaded("FooLibrary"));
|
||||||
|
Reference<container::XNameContainer> xLibrary(xBasLib->getByName("FooLibrary"), UNO_QUERY);
|
||||||
|
Any module(xLibrary->getByName("FooModule"));
|
||||||
|
CPPUNIT_ASSERT_EQUAL(module.get<OUString>(), OUString("Sub Main\nEnd Sub\n"));
|
||||||
|
|
||||||
// close
|
// close
|
||||||
Reference<util::XCloseable> xDocCloseable(xComponent, UNO_QUERY_THROW);
|
Reference<util::XCloseable>(xComponent, UNO_QUERY_THROW)->close(false);
|
||||||
xDocCloseable->close(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user