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

Side by Side Diff: goopdate/update_response_utils_unittest.cc

Issue 624713003: Keep only base/extractor.[cc|h]. (Closed) Base URL: https://chromium.googlesource.com/external/omaha.git@master
Patch Set: Created 6 years, 2 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
« no previous file with comments | « goopdate/update_response_utils.cc ('k') | goopdate/worker.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 #include "base/scoped_ptr.h"
17 #include "omaha/base/app_util.h"
18 #include "omaha/base/constants.h"
19 #include "omaha/base/error.h"
20 #include "omaha/goopdate/resource_manager.h"
21 #include "omaha/goopdate/update_response_utils.h"
22 #include "omaha/testing/unit_test.h"
23
24 namespace omaha {
25
26 namespace update_response_utils {
27
28 using xml::UpdateResponseResult;
29
30 namespace {
31
32 const TCHAR* const kAppId1 = _T("{CE9C207B-232D-492b-AF03-E590A8FBE8FB}");
33 const TCHAR* const kAppId2 = _T("{5881940A-72E4-4194-9DA5-4EA4089F867C}");
34 const TCHAR* const kAppId3 = _T("{2DE92FA0-C8A1-4368-8654-16FDBA91817D}");
35
36 const TCHAR* const kAppIdWithLowerCase =
37 _T("{C38D11BA-6244-45e3-AC2A-21F2077F2C10}");
38 const TCHAR* const kAppIdWithLowerCaseAllUpperCase =
39 _T("{C38D11BA-6244-45E3-AC2A-21F2077F2C10}");
40
41
42 const TCHAR* const kGOOPDATE_E_NO_SERVER_RESPONSEString =
43 _T("Installation failed due to a server side error. Please try again ")
44 _T("later. We apologize for the inconvenience.");
45
46 const UpdateResponseResult kUpdateAvailableResult =
47 std::make_pair(S_OK, _T(""));
48
49 const UpdateResponseResult kAppNotFoundResult = std::make_pair(
50 GOOPDATE_E_NO_SERVER_RESPONSE,
51 kGOOPDATE_E_NO_SERVER_RESPONSEString);
52
53 } // namespace
54
55
56 class UpdateResponseUtilsGetResultTest : public testing::Test {
57 protected:
58 virtual void SetUp() {
59 // Needed for error strings.
60 EXPECT_SUCCEEDED(ResourceManager::Create(
61 false, app_util::GetCurrentModuleDirectory(), _T("en")));
62
63 update_response_.reset(xml::UpdateResponse::Create());
64 }
65
66 virtual void TearDown() {
67 ResourceManager::Delete();
68 }
69
70 scoped_ptr<xml::UpdateResponse> update_response_;
71 };
72
73
74 // TODO(omaha): write tests.
75
76 TEST(UpdateResponseUtilsGetAppTest, AppNotFound) {
77 xml::response::Response response;
78 xml::response::App app;
79 app.status = kResponseStatusOkValue;
80 app.appid = kAppId1;
81 response.apps.push_back(app);
82
83 EXPECT_TRUE(NULL != GetApp(response, kAppId1));
84 EXPECT_EQ(NULL, GetApp(response, kAppId2));
85 }
86
87 TEST(UpdateResponseUtilsGetAppTest, MultipleApps) {
88 xml::response::Response response;
89 xml::response::App app;
90 app.status = kResponseStatusOkValue;
91 app.appid = kAppId1;
92 response.apps.push_back(app);
93 app.appid = kAppId2;
94 response.apps.push_back(app);
95
96 EXPECT_EQ(&response.apps[0], GetApp(response, kAppId1));
97 EXPECT_EQ(&response.apps[1], GetApp(response, kAppId2));
98 EXPECT_EQ(&response.apps[1], GetApp(response, kAppId2));
99 EXPECT_EQ(&response.apps[0], GetApp(response, kAppId1));
100 EXPECT_NE(GetApp(response, kAppId1), GetApp(response, kAppId2));
101 }
102
103 TEST(UpdateResponseUtilsGetAppTest, ResponseAppIdHasLowerCase) {
104 xml::response::Response response;
105 xml::response::App app;
106 app.status = kResponseStatusOkValue;
107 app.appid = kAppIdWithLowerCase;
108 response.apps.push_back(app);
109
110 EXPECT_EQ(&response.apps[0], GetApp(response, kAppIdWithLowerCase));
111 EXPECT_EQ(&response.apps[0],
112 GetApp(response, kAppIdWithLowerCaseAllUpperCase));
113 }
114
115 TEST(UpdateResponseUtilsGetAppTest, ResponseAppIdAllUpperCase) {
116 xml::response::Response response;
117 xml::response::App app;
118 app.status = kResponseStatusOkValue;
119 app.appid = kAppIdWithLowerCaseAllUpperCase;
120 response.apps.push_back(app);
121
122 EXPECT_EQ(&response.apps[0],
123 GetApp(response, kAppIdWithLowerCaseAllUpperCase));
124 EXPECT_EQ(&response.apps[0], GetApp(response, kAppIdWithLowerCase));
125 }
126
127 TEST_F(UpdateResponseUtilsGetResultTest, EmptyResponse) {
128 EXPECT_TRUE(kAppNotFoundResult ==
129 GetResult(update_response_.get(), kAppId1, _T("en")));
130 }
131
132 TEST_F(UpdateResponseUtilsGetResultTest, AppFound) {
133 xml::response::Response response;
134 xml::response::App app;
135 app.status = kResponseStatusOkValue;
136 app.update_check.status = kResponseStatusOkValue;
137 app.appid = kAppId1;
138 response.apps.push_back(app);
139 SetResponseForUnitTest(update_response_.get(), response);
140
141 EXPECT_TRUE(kUpdateAvailableResult ==
142 GetResult(update_response_.get(), kAppId1, _T("en")));
143 }
144
145 TEST_F(UpdateResponseUtilsGetResultTest, AppNotFound) {
146 xml::response::Response response;
147 xml::response::App app;
148 app.status = kResponseStatusOkValue;
149 app.update_check.status = kResponseStatusOkValue;
150 app.appid = kAppId1;
151 response.apps.push_back(app);
152 SetResponseForUnitTest(update_response_.get(), response);
153
154 EXPECT_TRUE(kAppNotFoundResult ==
155 GetResult(update_response_.get(), kAppId2, _T("en")));
156 }
157
158 TEST_F(UpdateResponseUtilsGetResultTest, MultipleApps) {
159 xml::response::Response response;
160 xml::response::App app;
161 app.status = kResponseStatusOkValue;
162 app.update_check.status = kResponseStatusOkValue;
163 app.appid = kAppId1;
164 response.apps.push_back(app);
165 app.appid = kAppId2;
166 response.apps.push_back(app);
167 SetResponseForUnitTest(update_response_.get(), response);
168
169 EXPECT_TRUE(kUpdateAvailableResult ==
170 GetResult(update_response_.get(), kAppId1, _T("en")));
171 EXPECT_TRUE(kUpdateAvailableResult ==
172 GetResult(update_response_.get(), kAppId2, _T("en")));
173 EXPECT_TRUE(kAppNotFoundResult ==
174 GetResult(update_response_.get(), kAppId3, _T("en")));
175 }
176
177 TEST_F(UpdateResponseUtilsGetResultTest, ResponseAppIdHasLowerCase) {
178 xml::response::Response response;
179 xml::response::App app;
180 app.status = kResponseStatusOkValue;
181 app.appid = kAppIdWithLowerCase;
182 response.apps.push_back(app);
183 SetResponseForUnitTest(update_response_.get(), response);
184
185 EXPECT_TRUE(kUpdateAvailableResult ==
186 GetResult(update_response_.get(), kAppIdWithLowerCase, _T("en")));
187 EXPECT_TRUE(kUpdateAvailableResult ==
188 GetResult(update_response_.get(), kAppIdWithLowerCaseAllUpperCase,
189 _T("en")));
190 }
191
192 TEST_F(UpdateResponseUtilsGetResultTest, ResponseAppIdAllUpperCase) {
193 xml::response::Response response;
194 xml::response::App app;
195 app.status = kResponseStatusOkValue;
196 app.appid = kAppIdWithLowerCaseAllUpperCase;
197 response.apps.push_back(app);
198 SetResponseForUnitTest(update_response_.get(), response);
199
200 EXPECT_TRUE(kUpdateAvailableResult ==
201 GetResult(update_response_.get(), kAppIdWithLowerCaseAllUpperCase,
202 _T("en")));
203 EXPECT_TRUE(kUpdateAvailableResult ==
204 GetResult(update_response_.get(), kAppIdWithLowerCase, _T("en")));
205 }
206
207 // TODO(omaha3): Add tests for GetResult from Omaha2's job_creator_unittest.cc.
208
209 } // namespace update_response_utils
210
211 } // namespace omaha
OLDNEW
« no previous file with comments | « goopdate/update_response_utils.cc ('k') | goopdate/worker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698