OLD | NEW |
| (Empty) |
1 // Copyright 2010 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 // Common include file for Omaha customization tests. | |
17 | |
18 #ifndef OMAHA_TESTING_OMAHA_CUSTOMIZATION_TEST_H_ | |
19 #define OMAHA_TESTING_OMAHA_CUSTOMIZATION_TEST_H_ | |
20 | |
21 #include "omaha/testing/unit_test.h" | |
22 | |
23 #ifdef GOOGLE_UPDATE_BUILD | |
24 // For Google Update builds, expect the values to be equal and for the | |
25 // interface names to exist. | |
26 | |
27 // Test fixture for a Google Update-specific interface name. | |
28 // Tests using this fixture must be in the global namespace. | |
29 #define TEST_GU_INT_F(test_fixture, test_name) TEST_F(test_fixture, test_name) | |
30 | |
31 // Expect the values to be equal only in the case of Google Update builds. | |
32 #define EXPECT_GU_EQ(expected, actual) EXPECT_EQ(expected, actual) | |
33 #define EXPECT_GU_STREQ(expected, actual) EXPECT_STREQ(expected, actual) | |
34 #define EXPECT_GU_TRUE(condition) EXPECT_TRUE(condition) | |
35 #define EXPECT_GU_FALSE(condition) EXPECT_FALSE(condition) | |
36 | |
37 // Expect an interface name that is Google Update-specific to have the uuid. | |
38 #define EXPECT_GU_ID_EQ(uuid, interface_id) \ | |
39 EXPECT_STREQ(CString(uuid).MakeUpper(), \ | |
40 omaha::GuidToString(interface_id)); | |
41 | |
42 #else | |
43 // For open source builds, expect the values to not be equal. (Interfaces | |
44 // should still exist.) | |
45 | |
46 #define TEST_GU_INT_F(test_fixture, test_name) TEST_F(test_fixture, test_name) | |
47 | |
48 #define EXPECT_GU_EQ(expected, actual) EXPECT_NE(expected, actual) | |
49 #define EXPECT_GU_STREQ(expected, actual) EXPECT_STRNE(expected, actual) | |
50 #define EXPECT_GU_TRUE(condition) EXPECT_FALSE(condition) | |
51 #define EXPECT_GU_FALSE(condition) EXPECT_TRUE(condition) | |
52 | |
53 #define EXPECT_GU_ID_EQ(uuid, interface_id) \ | |
54 EXPECT_STRNE(CString(uuid).MakeUpper(), \ | |
55 omaha::GuidToString(interface_id)); | |
56 | |
57 #endif | |
58 | |
59 | |
60 class OmahaCustomizationTypeLibComInterfaceTest : public testing::Test { | |
61 protected: | |
62 explicit OmahaCustomizationTypeLibComInterfaceTest(const CString& dll_name) | |
63 : dll_name_(dll_name), | |
64 type_lib_(NULL), | |
65 help_context_(UINT_MAX) { | |
66 } | |
67 | |
68 virtual void SetUp() { | |
69 CString omaha_dll_path; | |
70 omaha_dll_path.Format(_T("..\\staging\\%s"), dll_name_); | |
71 EXPECT_SUCCEEDED(::LoadTypeLib(omaha_dll_path, &type_lib_)); | |
72 } | |
73 | |
74 HRESULT GetDocumentation(int type_description_index) { | |
75 return type_lib_->GetDocumentation(type_description_index, | |
76 &item_name_, | |
77 &item_doc_string_, | |
78 &help_context_, | |
79 &help_file_); | |
80 } | |
81 | |
82 CString dll_name_; | |
83 ITypeLib* type_lib_; | |
84 | |
85 CComBSTR item_name_; | |
86 CComBSTR item_doc_string_; | |
87 unsigned long help_context_; // NOLINT | |
88 CComBSTR help_file_; | |
89 }; | |
90 | |
91 #endif // OMAHA_TESTING_OMAHA_CUSTOMIZATION_TEST_H_ | |
OLD | NEW |