Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Side by Side Diff: sandbox/src/unload_dll_test.cc

Issue 6126002: Remove base/scoped_handle_win.h stub and fix up all callers to use the new location and namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/scoped_handle_win.h" 5 #include "base/win/scoped_handle.h"
6 #include "testing/gtest/include/gtest/gtest.h"
7 #include "sandbox/src/sandbox.h" 6 #include "sandbox/src/sandbox.h"
8 #include "sandbox/src/sandbox_factory.h" 7 #include "sandbox/src/sandbox_factory.h"
9 #include "sandbox/src/target_services.h" 8 #include "sandbox/src/target_services.h"
10 #include "sandbox/tests/common/controller.h" 9 #include "sandbox/tests/common/controller.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11 11
12 namespace sandbox { 12 namespace sandbox {
13 13
14 // Loads and or unloads a DLL passed in the second parameter of argv. 14 // Loads and or unloads a DLL passed in the second parameter of argv.
15 // The first parameter of argv is 'L' = load, 'U' = unload or 'B' for both. 15 // The first parameter of argv is 'L' = load, 'U' = unload or 'B' for both.
16 SBOX_TESTS_COMMAND int UseOneDLL(int argc, wchar_t **argv) { 16 SBOX_TESTS_COMMAND int UseOneDLL(int argc, wchar_t **argv) {
17 if (argc != 2) 17 if (argc != 2)
18 return SBOX_TEST_FAILED_TO_RUN_TEST; 18 return SBOX_TEST_FAILED_TO_RUN_TEST;
19 int rv = SBOX_TEST_FAILED_TO_RUN_TEST; 19 int rv = SBOX_TEST_FAILED_TO_RUN_TEST;
20 20
21 wchar_t option = (argv[0])[0]; 21 wchar_t option = (argv[0])[0];
22 if ((option == L'L') || (option == L'B')) { 22 if ((option == L'L') || (option == L'B')) {
23 HMODULE module1 = ::LoadLibraryW(argv[1]); 23 HMODULE module1 = ::LoadLibraryW(argv[1]);
24 rv = (module1 == NULL) ? SBOX_TEST_FAILED : SBOX_TEST_SUCCEEDED; 24 rv = (module1 == NULL) ? SBOX_TEST_FAILED : SBOX_TEST_SUCCEEDED;
25 } 25 }
26 26
27 if ((option == L'U') || (option == L'B')) { 27 if ((option == L'U') || (option == L'B')) {
28 HMODULE module2 = ::GetModuleHandleW(argv[1]); 28 HMODULE module2 = ::GetModuleHandleW(argv[1]);
29 rv = ::FreeLibrary(module2) ? SBOX_TEST_SUCCEEDED : SBOX_TEST_FAILED; 29 rv = ::FreeLibrary(module2) ? SBOX_TEST_SUCCEEDED : SBOX_TEST_FAILED;
30 } 30 }
31 return rv; 31 return rv;
32 } 32 }
33 33
34 // Opens an event passed as the first parameter of argv. 34 // Opens an event passed as the first parameter of argv.
35 SBOX_TESTS_COMMAND int SimpleOpenEvent(int argc, wchar_t **argv) { 35 SBOX_TESTS_COMMAND int SimpleOpenEvent(int argc, wchar_t **argv) {
36 if (argc != 1) 36 if (argc != 1)
37 return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND; 37 return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND;
38 38
39 ScopedHandle event_open(::OpenEvent(SYNCHRONIZE, FALSE, argv[0])); 39 base::win::ScopedHandle event_open(::OpenEvent(SYNCHRONIZE, FALSE, argv[0]));
40 return event_open.Get() ? SBOX_TEST_SUCCEEDED : SBOX_TEST_FAILED; 40 return event_open.Get() ? SBOX_TEST_SUCCEEDED : SBOX_TEST_FAILED;
41 } 41 }
42 42
43 TEST(UnloadDllTest, BaselineAvicapDll) { 43 TEST(UnloadDllTest, BaselineAvicapDll) {
44 TestRunner runner; 44 TestRunner runner;
45 runner.SetTestState(BEFORE_REVERT); 45 runner.SetTestState(BEFORE_REVERT);
46 runner.SetTimeout(2000); 46 runner.SetTimeout(2000);
47 // Add a sync rule, because that ensures that the interception agent has 47 // Add a sync rule, because that ensures that the interception agent has
48 // more than one item in its internal table. 48 // more than one item in its internal table.
49 EXPECT_TRUE(runner.AddRule(TargetPolicy::SUBSYS_SYNC, 49 EXPECT_TRUE(runner.AddRule(TargetPolicy::SUBSYS_SYNC,
(...skipping 16 matching lines...) Expand all
66 } 66 }
67 67
68 // Flaky: http://crbug.com/38404 68 // Flaky: http://crbug.com/38404
69 TEST(UnloadDllTest, FLAKY_UnloadAviCapDllWithPatching) { 69 TEST(UnloadDllTest, FLAKY_UnloadAviCapDllWithPatching) {
70 TestRunner runner; 70 TestRunner runner;
71 runner.SetTimeout(2000); 71 runner.SetTimeout(2000);
72 runner.SetTestState(BEFORE_REVERT); 72 runner.SetTestState(BEFORE_REVERT);
73 sandbox::TargetPolicy* policy = runner.GetPolicy(); 73 sandbox::TargetPolicy* policy = runner.GetPolicy();
74 policy->AddDllToUnload(L"avicap32.dll"); 74 policy->AddDllToUnload(L"avicap32.dll");
75 75
76 ScopedHandle handle1(::CreateEvent(NULL, FALSE, FALSE, L"tst0001")); 76 base::win::ScopedHandle handle1(::CreateEvent(
77 NULL, FALSE, FALSE, L"tst0001"));
77 78
78 // Add a couple of rules that ensures that the interception agent add EAT 79 // Add a couple of rules that ensures that the interception agent add EAT
79 // patching on the client which makes sure that the unload dll record does 80 // patching on the client which makes sure that the unload dll record does
80 // not interact badly with them. 81 // not interact badly with them.
81 EXPECT_TRUE(runner.AddRule(TargetPolicy::SUBSYS_REGISTRY, 82 EXPECT_TRUE(runner.AddRule(TargetPolicy::SUBSYS_REGISTRY,
82 TargetPolicy::REG_ALLOW_ANY, 83 TargetPolicy::REG_ALLOW_ANY,
83 L"HKEY_LOCAL_MACHINE\\Software\\Microsoft")); 84 L"HKEY_LOCAL_MACHINE\\Software\\Microsoft"));
84 EXPECT_TRUE(runner.AddRule(TargetPolicy::SUBSYS_SYNC, 85 EXPECT_TRUE(runner.AddRule(TargetPolicy::SUBSYS_SYNC,
85 TargetPolicy::EVENTS_ALLOW_ANY, L"tst0001")); 86 TargetPolicy::EVENTS_ALLOW_ANY, L"tst0001"));
86 87
87 EXPECT_EQ(SBOX_TEST_FAILED, runner.RunTest(L"UseOneDLL L avicap32.dll")); 88 EXPECT_EQ(SBOX_TEST_FAILED, runner.RunTest(L"UseOneDLL L avicap32.dll"));
88 89
89 runner.SetTestState(AFTER_REVERT); 90 runner.SetTestState(AFTER_REVERT);
90 EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest(L"SimpleOpenEvent tst0001")); 91 EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest(L"SimpleOpenEvent tst0001"));
91 } 92 }
92 93
93 } // namespace sandbox 94 } // namespace sandbox
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698