OLD | NEW |
| (Empty) |
1 // Copyright 2008-2009 Google Inc. | |
2 // | |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | |
4 // you may not use this file except in compliance with the License. | |
5 // You may obtain a copy of the License at | |
6 // | |
7 // http://www.apache.org/licenses/LICENSE-2.0 | |
8 // | |
9 // Unless required by applicable law or agreed to in writing, software | |
10 // distributed under the License is distributed on an "AS IS" BASIS, | |
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
12 // See the License for the specific language governing permissions and | |
13 // limitations under the License. | |
14 // ======================================================================== | |
15 | |
16 #include "omaha/base/app_util.h" | |
17 #include "omaha/base/path.h" | |
18 #include "omaha/base/vistautil.h" | |
19 #include "omaha/setup/setup_service.h" | |
20 #include "omaha/testing/unit_test.h" | |
21 | |
22 namespace omaha { | |
23 | |
24 class SetupServiceTest : public testing::Test { | |
25 protected: | |
26 static void SetUpTestCase() { | |
27 // The ServiceModule has it's own ATL module. ATL does not like having | |
28 // multiple ATL modules. This TestCase saves and restore the original ATL | |
29 // module to get around ATL's limitation. This is a hack. | |
30 original_atl_module_ = _pAtlModule; | |
31 _pAtlModule = NULL; | |
32 } | |
33 | |
34 static void TearDownTestCase() { | |
35 _pAtlModule = original_atl_module_; | |
36 } | |
37 | |
38 static HRESULT DeleteUpdate3Service() { | |
39 return SetupUpdate3Service::DeleteService(); | |
40 } | |
41 | |
42 static HRESULT DeleteMediumService() { | |
43 return SetupUpdateMediumService::DeleteService(); | |
44 } | |
45 | |
46 static CAtlModule* original_atl_module_; | |
47 }; | |
48 | |
49 CAtlModule* SetupServiceTest::original_atl_module_ = NULL; | |
50 | |
51 // TODO(omaha): Test SetupServiceTest | |
52 | |
53 TEST_F(SetupServiceTest, InstallService_FileDoesNotExist) { | |
54 if (!vista_util::IsUserAdmin()) { | |
55 std::wcout << _T("\tTest did not run because the user is not an admin.") | |
56 << std::endl; | |
57 return; | |
58 } | |
59 | |
60 DeleteUpdate3Service(); | |
61 DeleteMediumService(); | |
62 | |
63 CString service_path = ConcatenatePath(app_util::GetCurrentModuleDirectory(), | |
64 _T("NoSuchFile.exe")); | |
65 | |
66 // The Windows service registration APIs do not rely on the file existing. | |
67 EXPECT_SUCCEEDED( | |
68 SetupUpdate3Service::InstallService(service_path)); | |
69 | |
70 EXPECT_SUCCEEDED( | |
71 SetupUpdateMediumService::InstallService(service_path)); | |
72 | |
73 EXPECT_SUCCEEDED(DeleteUpdate3Service()); | |
74 EXPECT_SUCCEEDED(DeleteMediumService()); | |
75 } | |
76 | |
77 } // namespace omaha | |
OLD | NEW |