Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
ad0540a7
Kaydet (Commit)
ad0540a7
authored
Tem 22, 2011
tarafından
Michael Meeks
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
first cut at an automated / random document / redlining test
üst
e75fc376
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
160 additions
and
0 deletions
+160
-0
swmodule.hxx
sw/inc/swmodule.hxx
+1
-0
swdoc-test.cxx
sw/qa/core/swdoc-test.cxx
+152
-0
swmodul1.cxx
sw/source/ui/app/swmodul1.cxx
+7
-0
No files found.
sw/inc/swmodule.hxx
Dosyayı görüntüle @
ad0540a7
...
@@ -201,6 +201,7 @@ public:
...
@@ -201,6 +201,7 @@ public:
sal_uInt16
GetRedlineAuthor
();
sal_uInt16
GetRedlineAuthor
();
const
String
&
GetRedlineAuthor
(
sal_uInt16
nPos
);
const
String
&
GetRedlineAuthor
(
sal_uInt16
nPos
);
sal_uInt16
InsertRedlineAuthor
(
const
String
&
rAuthor
);
sal_uInt16
InsertRedlineAuthor
(
const
String
&
rAuthor
);
void
SetRedlineAuthor
(
const
String
&
rAuthor
);
// for unit tests
void
GetInsertAuthorAttr
(
sal_uInt16
nAuthor
,
SfxItemSet
&
rSet
);
void
GetInsertAuthorAttr
(
sal_uInt16
nAuthor
,
SfxItemSet
&
rSet
);
void
GetDeletedAuthorAttr
(
sal_uInt16
nAuthor
,
SfxItemSet
&
rSet
);
void
GetDeletedAuthorAttr
(
sal_uInt16
nAuthor
,
SfxItemSet
&
rSet
);
...
...
sw/qa/core/swdoc-test.cxx
Dosyayı görüntüle @
ad0540a7
...
@@ -59,6 +59,8 @@
...
@@ -59,6 +59,8 @@
#include "docsh.hxx"
#include "docsh.hxx"
#include "shellres.hxx"
#include "shellres.hxx"
#include "docufld.hxx"
#include "docufld.hxx"
#include "swcrsr.hxx"
#include "swmodule.hxx"
SO2_DECL_REF
(
SwDocShell
)
SO2_DECL_REF
(
SwDocShell
)
SO2_IMPL_REF
(
SwDocShell
)
SO2_IMPL_REF
(
SwDocShell
)
...
@@ -170,9 +172,159 @@ void SwDocTest::testFileNameFields()
...
@@ -170,9 +172,159 @@ void SwDocTest::testFileNameFields()
m_xDocShRef
->
DoInitNew
(
0
);
m_xDocShRef
->
DoInitNew
(
0
);
}
}
static
int
getRand
(
int
modulus
)
{
if
(
modulus
<=
0
)
return
0
;
return
rand
()
%
modulus
;
}
static
rtl
::
OUString
getRandString
()
{
static
rtl
::
OUString
aText
(
rtl
::
OUString
::
createFromAscii
(
"AAAAA BBBB CCC DD E
\n
"
));
int
s
=
getRand
(
aText
.
getLength
());
int
j
=
getRand
(
aText
.
getLength
()
-
s
);
rtl
::
OUString
aRet
(
aText
+
s
,
j
);
if
(
!
getRand
(
5
))
aRet
+=
rtl
::
OUString
(
sal_Unicode
(
'\n'
));
// fprintf (stderr, "rand string '%s'\n", OUStringToOString(aRet, RTL_TEXTENCODING_UTF8).getStr());
return
aRet
;
}
#ifdef COMPLEX
static
SwPosition
getRandomPosition
(
SwDoc
*
pDoc
,
int
nOffset
)
{
SwPaM
aPam
(
pDoc
->
GetNodes
());
SwCursor
aCrs
(
*
aPam
.
Start
(),
0
,
false
);
for
(
int
sskip
=
getRand
(
nOffset
);
sskip
>
0
;
sskip
--
)
aCrs
.
GoNextSentence
();
aCrs
.
GoNextCell
(
getRand
(
50
));
return
*
aCrs
.
GetPoint
();
}
#endif
void
SwDocTest
::
randomTest
()
void
SwDocTest
::
randomTest
()
{
{
CPPUNIT_ASSERT_MESSAGE
(
"SwDoc::IsRedlineOn()"
,
!
m_pDoc
->
IsRedlineOn
());
CPPUNIT_ASSERT_MESSAGE
(
"SwDoc::IsRedlineOn()"
,
!
m_pDoc
->
IsRedlineOn
());
RedlineMode_t
modes
[]
=
{
nsRedlineMode_t
::
REDLINE_NONE
,
nsRedlineMode_t
::
REDLINE_ON
,
nsRedlineMode_t
::
REDLINE_SHOW_MASK
,
nsRedlineMode_t
::
REDLINE_ON
|
nsRedlineMode_t
::
REDLINE_SHOW_MASK
,
nsRedlineMode_t
::
REDLINE_ON
|
nsRedlineMode_t
::
REDLINE_IGNORE
,
nsRedlineMode_t
::
REDLINE_ON
|
nsRedlineMode_t
::
REDLINE_IGNORE
|
nsRedlineMode_t
::
REDLINE_SHOW_MASK
,
nsRedlineMode_t
::
REDLINE_ON
|
nsRedlineMode_t
::
REDLINE_SHOW_INSERT
,
nsRedlineMode_t
::
REDLINE_ON
|
nsRedlineMode_t
::
REDLINE_SHOW_DELETE
};
static
const
char
*
authors
[]
=
{
"Jim"
,
"Bob"
,
"JimBobina"
,
"Helga"
,
"Gertrude"
,
"Spagna"
,
"Hurtleweed"
};
for
(
sal_uInt16
rlm
=
0
;
rlm
<
SAL_N_ELEMENTS
(
modes
);
rlm
++
)
{
m_pDoc
->
ClearDoc
();
// setup redlining
m_pDoc
->
SetRedlineMode
(
modes
[
rlm
]);
SW_MOD
()
->
SetRedlineAuthor
(
rtl
::
OUString
::
createFromAscii
(
authors
[
0
]));
for
(
int
i
=
0
;
i
<
2000
;
i
++
)
{
#ifdef COMPLEX
SwPaM
aPam
(
m_pDoc
->
GetNodes
());
SwCursor
aCrs
(
getRandomPosition
(
m_pDoc
,
i
/
20
),
0
,
false
);
aCrs
.
SetMark
();
aCrs
.
GoNextCell
(
getRand
(
30
));
#else // simple:
SwPaM
aPam
(
m_pDoc
->
GetNodes
());
SwCursor
aCrs
(
*
aPam
.
Start
(),
NULL
,
false
);
#endif
switch
(
getRand
(
i
<
50
?
3
:
6
))
{
// insert ops first
case
0
:
{
m_pDoc
->
InsertString
(
aCrs
,
getRandString
());
break
;
}
case
1
:
break
;
case
2
:
{
// switch author
int
a
=
getRand
(
SAL_N_ELEMENTS
(
authors
));
SW_MOD
()
->
SetRedlineAuthor
(
rtl
::
OUString
::
createFromAscii
(
authors
[
a
]));
break
;
}
#ifdef COMPLEX
// movement / deletion ops later
case
3
:
// deletion
switch
(
getRand
(
6
))
{
case
0
:
m_pDoc
->
DelFullPara
(
aCrs
);
break
;
case
1
:
m_pDoc
->
DeleteRange
(
aCrs
);
break
;
case
2
:
m_pDoc
->
DeleteAndJoin
(
aCrs
,
!!
getRand
(
1
));
break
;
case
3
:
default
:
m_pDoc
->
Overwrite
(
aCrs
,
getRandString
());
break
;
}
break
;
case
4
:
{
// movement
IDocumentContentOperations
::
SwMoveFlags
nFlags
=
(
IDocumentContentOperations
::
SwMoveFlags
)
(
getRand
(
1
)
?
// FIXME: puterb this more ?
IDocumentContentOperations
::
DOC_MOVEDEFAULT
:
IDocumentContentOperations
::
DOC_MOVEALLFLYS
|
IDocumentContentOperations
::
DOC_CREATEUNDOOBJ
|
IDocumentContentOperations
::
DOC_MOVEREDLINES
|
IDocumentContentOperations
::
DOC_NO_DELFRMS
);
SwPosition
aTo
(
getRandomPosition
(
m_pDoc
,
i
/
10
));
m_pDoc
->
MoveRange
(
aCrs
,
aTo
,
nFlags
);
break
;
}
#endif
case
5
:
break
;
// undo / redo ?
default
:
break
;
}
#ifdef COMPLEX
SwPosition
start
(
m_pDoc
->
GetNodes
());
SwPosition
end
(
m_pDoc
->
GetNodes
().
GetEndOfContent
());
CheckNodesRange
(
start
.
nNode
,
end
.
nNode
,
sal_True
);
#endif
}
/* fprintf (stderr, "write it !\n");
#ifdef COMPLEX
SfxFilter aFilter(rtl::OUString::createFromAscii("writer8"),
rtl::OUString(), 0, 0, rtl::OUString(), 0, rtl::OUString(),
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CXML")),
rtl::OUString() );
#else
SfxFilter aFilter(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Text")),
rtl::OUString(), 0, 0, rtl::OUString(), 0, rtl::OUString(),
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TEXT")), rtl::OUString() );
#endif
SfxMedium aDstMed(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("file:///tmp/test.txt")),
STREAM_STD_READWRITE, true);
aDstMed.SetFilter(&aFilter);
m_xDocShRef->DoSaveAs(aDstMed);
m_xDocShRef->DoSaveCompleted(&aDstMed);
m_xDocShRef->DoInitNew(0);*/
#ifndef COMPLEX
return
;
#endif
}
}
}
SwDocTest
::
SwDocTest
()
SwDocTest
::
SwDocTest
()
...
...
sw/source/ui/app/swmodul1.cxx
Dosyayı görüntüle @
ad0540a7
...
@@ -427,6 +427,13 @@ sal_uInt16 SwModule::GetRedlineAuthor()
...
@@ -427,6 +427,13 @@ sal_uInt16 SwModule::GetRedlineAuthor()
return
InsertRedlineAuthor
(
sActAuthor
);
return
InsertRedlineAuthor
(
sActAuthor
);
}
}
void
SwModule
::
SetRedlineAuthor
(
const
String
&
rAuthor
)
{
bAuthorInitialised
=
sal_True
;
sActAuthor
=
rAuthor
;
InsertRedlineAuthor
(
sActAuthor
);
}
const
String
&
SwModule
::
GetRedlineAuthor
(
sal_uInt16
nPos
)
const
String
&
SwModule
::
GetRedlineAuthor
(
sal_uInt16
nPos
)
{
{
OSL_ENSURE
(
nPos
<
pAuthorNames
->
Count
(),
"author not found!"
);
//#i45342# RTF doc with no author table caused reader to crash
OSL_ENSURE
(
nPos
<
pAuthorNames
->
Count
(),
"author not found!"
);
//#i45342# RTF doc with no author table caused reader to crash
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment