Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
3c9067de
Commit
3c9067de
authored
Oct 02, 2009
by
Vincent Povirk
Committed by
Alexandre Julliard
Oct 05, 2009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ole32/tests: Add test for IStorage::Revert.
parent
d6e020fd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
157 additions
and
0 deletions
+157
-0
storage32.c
dlls/ole32/tests/storage32.c
+157
-0
No files found.
dlls/ole32/tests/storage32.c
View file @
3c9067de
...
...
@@ -1029,6 +1029,162 @@ static void test_transact(void)
ok
(
r
==
TRUE
,
"deleted file
\n
"
);
}
static
void
test_revert
(
void
)
{
IStorage
*
stg
=
NULL
,
*
stg2
=
NULL
,
*
stg3
=
NULL
;
HRESULT
r
;
IStream
*
stm
=
NULL
,
*
stm2
=
NULL
;
static
const
WCHAR
stmname
[]
=
{
'C'
,
'O'
,
'N'
,
'T'
,
'E'
,
'N'
,
'T'
,
'S'
,
0
};
static
const
WCHAR
stmname2
[]
=
{
'F'
,
'O'
,
'O'
,
0
};
static
const
WCHAR
stgname
[]
=
{
'P'
,
'E'
,
'R'
,
'M'
,
'S'
,
'T'
,
'G'
,
0
};
static
const
WCHAR
stgname2
[]
=
{
'T'
,
'E'
,
'M'
,
'P'
,
'S'
,
'T'
,
'G'
,
0
};
STATSTG
statstg
;
DeleteFileA
(
filenameA
);
/* create the file */
r
=
StgCreateDocfile
(
filename
,
STGM_CREATE
|
STGM_SHARE_EXCLUSIVE
|
STGM_READWRITE
|
STGM_TRANSACTED
,
0
,
&
stg
);
ok
(
r
==
S_OK
,
"StgCreateDocfile failed
\n
"
);
/* commit a new stream and storage */
r
=
IStorage_CreateStream
(
stg
,
stmname2
,
STGM_SHARE_EXCLUSIVE
|
STGM_READWRITE
,
0
,
0
,
&
stm
);
ok
(
r
==
S_OK
,
"IStorage->CreateStream failed
\n
"
);
r
=
IStream_Write
(
stm
,
"this is stream 1
\n
"
,
16
,
NULL
);
ok
(
r
==
S_OK
,
"IStream->Write failed
\n
"
);
r
=
IStorage_CreateStorage
(
stg
,
stgname
,
STGM_READWRITE
|
STGM_SHARE_EXCLUSIVE
,
0
,
0
,
&
stg2
);
ok
(
r
==
S_OK
,
"IStorage->CreateStorage failed, hr=%08x
\n
"
,
r
);
if
(
r
==
S_OK
)
{
/* Create two substorages but only commit one */
r
=
IStorage_CreateStorage
(
stg2
,
stgname
,
STGM_READWRITE
|
STGM_SHARE_EXCLUSIVE
,
0
,
0
,
&
stg3
);
ok
(
r
==
S_OK
,
"IStorage->CreateStorage failed, hr=%08x
\n
"
,
r
);
if
(
r
==
S_OK
)
IStorage_Release
(
stg3
);
r
=
IStorage_Commit
(
stg
,
0
);
ok
(
r
==
S_OK
,
"IStorage->Commit failed
\n
"
);
r
=
IStorage_CreateStorage
(
stg2
,
stgname2
,
STGM_READWRITE
|
STGM_SHARE_EXCLUSIVE
,
0
,
0
,
&
stg3
);
ok
(
r
==
S_OK
,
"IStorage->CreateStorage failed, hr=%08x
\n
"
,
r
);
if
(
r
==
S_OK
)
IStorage_Release
(
stg3
);
}
/* now create a stream and storage, then revert */
r
=
IStorage_CreateStream
(
stg
,
stmname
,
STGM_SHARE_EXCLUSIVE
|
STGM_READWRITE
,
0
,
0
,
&
stm2
);
ok
(
r
==
S_OK
,
"IStorage->CreateStream failed
\n
"
);
r
=
IStream_Write
(
stm2
,
"this is stream 2
\n
"
,
16
,
NULL
);
ok
(
r
==
S_OK
,
"IStream->Write failed
\n
"
);
r
=
IStorage_CreateStorage
(
stg
,
stgname2
,
STGM_READWRITE
|
STGM_SHARE_EXCLUSIVE
,
0
,
0
,
&
stg3
);
ok
(
r
==
S_OK
,
"IStorage->CreateStorage failed, hr=%08x
\n
"
,
r
);
r
=
IStorage_Revert
(
stg
);
/* all open objects become invalid */
todo_wine
{
r
=
IStream_Write
(
stm
,
"this shouldn't work
\n
"
,
20
,
NULL
);
ok
(
r
==
STG_E_REVERTED
,
"IStream_Write should fail %08x
\n
"
,
r
);
r
=
IStream_Write
(
stm2
,
"this shouldn't work
\n
"
,
20
,
NULL
);
ok
(
r
==
STG_E_REVERTED
,
"IStream_Write should fail %08x
\n
"
,
r
);
r
=
IStorage_Stat
(
stg2
,
&
statstg
,
STATFLAG_NONAME
);
ok
(
r
==
STG_E_REVERTED
,
"IStorage_Stat should fail %08x
\n
"
,
r
);
r
=
IStorage_Stat
(
stg3
,
&
statstg
,
STATFLAG_NONAME
);
ok
(
r
==
STG_E_REVERTED
,
"IStorage_Stat should fail %08x
\n
"
,
r
);
}
IStream_Release
(
stm
);
IStream_Release
(
stm2
);
IStorage_Release
(
stg2
);
IStorage_Release
(
stg3
);
r
=
IStorage_OpenStream
(
stg
,
stmname
,
NULL
,
STGM_SHARE_DENY_NONE
|
STGM_READ
,
0
,
&
stm
);
ok
(
r
==
STG_E_INVALIDFLAG
,
"IStorage->OpenStream failed %08x
\n
"
,
r
);
r
=
IStorage_OpenStream
(
stg
,
stmname
,
NULL
,
STGM_DELETEONRELEASE
|
STGM_SHARE_EXCLUSIVE
|
STGM_READWRITE
,
0
,
&
stm
);
ok
(
r
==
STG_E_INVALIDFUNCTION
,
"IStorage->OpenStream failed %08x
\n
"
,
r
);
r
=
IStorage_OpenStream
(
stg
,
stmname
,
NULL
,
STGM_TRANSACTED
|
STGM_SHARE_EXCLUSIVE
|
STGM_READWRITE
,
0
,
&
stm
);
ok
(
r
==
STG_E_INVALIDFUNCTION
,
"IStorage->OpenStream failed %08x
\n
"
,
r
);
r
=
IStorage_OpenStorage
(
stg
,
stmname
,
NULL
,
STGM_TRANSACTED
|
STGM_SHARE_EXCLUSIVE
|
STGM_READWRITE
,
NULL
,
0
,
&
stg2
);
ok
(
r
==
STG_E_FILENOTFOUND
,
"IStorage->OpenStream failed %08x
\n
"
,
r
);
todo_wine
{
r
=
IStorage_OpenStream
(
stg
,
stmname
,
NULL
,
STGM_SHARE_EXCLUSIVE
|
STGM_READWRITE
,
0
,
&
stm
);
ok
(
r
==
STG_E_FILENOTFOUND
,
"IStorage->OpenStream should fail %08x
\n
"
,
r
);
}
if
(
r
==
S_OK
)
IStream_Release
(
stm
);
todo_wine
{
r
=
IStorage_OpenStorage
(
stg
,
stgname2
,
NULL
,
STGM_SHARE_EXCLUSIVE
|
STGM_READWRITE
,
NULL
,
0
,
&
stg2
);
ok
(
r
==
STG_E_FILENOTFOUND
,
"IStorage->OpenStorage should fail %08x
\n
"
,
r
);
}
if
(
r
==
S_OK
)
IStorage_Release
(
stg2
);
r
=
IStorage_OpenStorage
(
stg
,
stmname2
,
NULL
,
STGM_TRANSACTED
|
STGM_SHARE_EXCLUSIVE
|
STGM_READWRITE
,
NULL
,
0
,
&
stg2
);
ok
(
r
==
STG_E_FILENOTFOUND
,
"IStorage->OpenStream failed %08x
\n
"
,
r
);
r
=
IStorage_OpenStream
(
stg
,
stmname2
,
NULL
,
STGM_SHARE_EXCLUSIVE
|
STGM_READWRITE
,
0
,
&
stm
);
ok
(
r
==
S_OK
,
"IStorage->OpenStream should succeed %08x
\n
"
,
r
);
if
(
r
==
S_OK
)
IStream_Release
(
stm
);
r
=
IStorage_OpenStorage
(
stg
,
stgname
,
NULL
,
STGM_SHARE_EXCLUSIVE
|
STGM_READWRITE
,
NULL
,
0
,
&
stg2
);
ok
(
r
==
S_OK
,
"IStorage->OpenStorage should succeed %08x
\n
"
,
r
);
if
(
r
==
S_OK
)
{
r
=
IStorage_OpenStorage
(
stg2
,
stgname
,
NULL
,
STGM_SHARE_EXCLUSIVE
|
STGM_READWRITE
,
NULL
,
0
,
&
stg3
);
ok
(
r
==
S_OK
,
"IStorage->OpenStorage should succeed %08x
\n
"
,
r
);
if
(
r
==
S_OK
)
IStorage_Release
(
stg3
);
r
=
IStorage_OpenStorage
(
stg2
,
stgname2
,
NULL
,
STGM_SHARE_EXCLUSIVE
|
STGM_READWRITE
,
NULL
,
0
,
&
stg3
);
todo_wine
ok
(
r
==
STG_E_FILENOTFOUND
,
"IStorage->OpenStorage should fail %08x
\n
"
,
r
);
if
(
r
==
S_OK
)
IStorage_Release
(
stg3
);
IStorage_Release
(
stg2
);
}
IStorage_Release
(
stg
);
r
=
DeleteFileA
(
filenameA
);
ok
(
r
==
TRUE
,
"deleted file
\n
"
);
/* Revert only invalidates objects in transacted mode */
r
=
StgCreateDocfile
(
filename
,
STGM_CREATE
|
STGM_SHARE_EXCLUSIVE
|
STGM_READWRITE
,
0
,
&
stg
);
ok
(
r
==
S_OK
,
"StgCreateDocfile failed
\n
"
);
r
=
IStorage_CreateStream
(
stg
,
stmname2
,
STGM_SHARE_EXCLUSIVE
|
STGM_READWRITE
,
0
,
0
,
&
stm
);
ok
(
r
==
S_OK
,
"IStorage->CreateStream failed
\n
"
);
r
=
IStorage_Revert
(
stg
);
todo_wine
ok
(
r
==
S_OK
,
"IStorage->Revert failed %08x
\n
"
,
r
);
r
=
IStream_Write
(
stm
,
"this works
\n
"
,
11
,
NULL
);
ok
(
r
==
S_OK
,
"IStream_Write should succeed %08x
\n
"
,
r
);
IStream_Release
(
stm
);
IStream_Release
(
stg
);
r
=
DeleteFileA
(
filenameA
);
ok
(
r
==
TRUE
,
"deleted file
\n
"
);
}
static
void
test_ReadClassStm
(
void
)
{
CLSID
clsid
;
...
...
@@ -1584,6 +1740,7 @@ START_TEST(storage32)
test_storage_refcount
();
test_streamenum
();
test_transact
();
test_revert
();
test_ReadClassStm
();
test_access
();
test_writeclassstg
();
...
...
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