summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2014-08-08 11:29:05 -0400
committerKohei Yoshida <kohei.yoshida@collabora.com>2014-08-08 11:31:22 -0400
commitf20dac7df4bab6fe5954c330880ebb4512b5d2c0 (patch)
treeae08c2f9cac6601dbc5ef0db228bea9c05fc49b5
parentb4f775daf031d7d28505825ed0e7b4e1d19f0e1b (diff)
bnc#885548: Write test for this.
Change-Id: Ifbd4502a5e49dfbb60301b935291ed0ce65da706
-rw-r--r--sc/inc/scmod.hxx2
-rw-r--r--sc/qa/unit/subsequent_export-test.cxx65
2 files changed, 66 insertions, 1 deletions
diff --git a/sc/inc/scmod.hxx b/sc/inc/scmod.hxx
index 1e68839bc401..df6bbfe1a6f2 100644
--- a/sc/inc/scmod.hxx
+++ b/sc/inc/scmod.hxx
@@ -198,7 +198,7 @@ SC_DLLPUBLIC void SetAppOptions ( const ScAppOptions& rO
svtools::ColorConfig& GetColorConfig();
SvtAccessibilityOptions& GetAccessOptions();
SvtCTLOptions& GetCTLOptions();
- SvtUserOptions& GetUserOptions();
+ SC_DLLPUBLIC SvtUserOptions& GetUserOptions();
void ModifyOptions( const SfxItemSet& rOptSet );
diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx
index d1e1842d2ed8..0be4d5e2f2d8 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -32,6 +32,7 @@
#include "editutil.hxx"
#include "scopetools.hxx"
#include "cellvalue.hxx"
+#include "docfunc.hxx"
#include <postit.hxx>
#include <tokenstringcontext.hxx>
#include <chgtrack.hxx>
@@ -49,6 +50,8 @@
#include <editeng/fontitem.hxx>
#include <editeng/udlnitem.hxx>
#include <formula/grammar.hxx>
+#include <unotools/useroptions.hxx>
+#include <tools/datetime.hxx>
#include <test/xmltesttools.hxx>
@@ -1481,8 +1484,64 @@ void ScExportTest::testTrackChangesSimpleXLSX()
return true;
}
+ bool checkRevisionUserAndTime( ScDocument& rDoc, const OUString& rOwnerName )
+ {
+ ScChangeTrack* pCT = rDoc.GetChangeTrack();
+ if (!pCT)
+ {
+ cerr << "Change track instance doesn't exist." << endl;
+ return false;
+ }
+
+ ScChangeAction* pAction = pCT->GetLast();
+ if (pAction->GetUser() != "Kohei Yoshida")
+ {
+ cerr << "Wrong user name." << endl;
+ return false;
+ }
+
+ DateTime aDT = pAction->GetDateTimeUTC();
+ if (aDT.GetYear() != 2014 || aDT.GetMonth() != 7 || aDT.GetDay() != 11)
+ {
+ cerr << "Wrong time stamp." << endl;
+ return false;
+ }
+
+ // Insert a new record to make sure the user and date-time are correct.
+ rDoc.SetString(ScAddress(1,8,0), "New String");
+ ScCellValue aEmpty;
+ pCT->AppendContent(ScAddress(1,8,0), aEmpty);
+ pAction = pCT->GetLast();
+ if (!pAction)
+ {
+ cerr << "Failed to retrieve last revision." << endl;
+ return false;
+ }
+
+ if (rOwnerName != pAction->GetUser())
+ {
+ cerr << "Wrong user name." << endl;
+ return false;
+ }
+
+ DateTime aDTNew = pAction->GetDateTimeUTC();
+ if (aDTNew <= aDT)
+ {
+ cerr << "Time stamp of the new revision should be more recent than that of the last revision." << endl;
+ return false;
+ }
+
+ return true;
+ }
+
} aTest;
+ SvtUserOptions& rUserOpt = SC_MOD()->GetUserOptions();
+ rUserOpt.SetToken(USER_OPT_FIRSTNAME, "Export");
+ rUserOpt.SetToken(USER_OPT_LASTNAME, "Test");
+
+ OUString aOwnerName = rUserOpt.GetFirstName() + " " + rUserOpt.GetLastName();
+
// First, test the xls variant.
ScDocShellRef xDocSh = loadDoc("track-changes/simple-cell-changes.", XLS);
@@ -1506,6 +1565,9 @@ void ScExportTest::testTrackChangesSimpleXLSX()
pAction->GetDescription(aDesc, pDoc);
CPPUNIT_ASSERT_EQUAL(OUString("Cell B2 changed from '<empty>' to '1'"), aDesc);
+ bGood = aTest.checkRevisionUserAndTime(*pDoc, aOwnerName);
+ CPPUNIT_ASSERT_MESSAGE("Check revision and time failed after reload (xls).", bGood);
+
xDocSh2->DoClose();
// Now, test the xlsx variant the same way.
@@ -1522,6 +1584,9 @@ void ScExportTest::testTrackChangesSimpleXLSX()
bGood = aTest.check(*pDoc);
CPPUNIT_ASSERT_MESSAGE("Check after reload failed (xlsx).", bGood);
+ bGood = aTest.checkRevisionUserAndTime(*pDoc, aOwnerName);
+ CPPUNIT_ASSERT_MESSAGE("Check revision and time failed after reload (xlsx).", bGood);
+
xDocSh2->DoClose();
}