| 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 <windows.h> | |
| 17 #include <atlstr.h> | |
| 18 #include "omaha/base/app_util.h" | |
| 19 #include "omaha/base/error.h" | |
| 20 #include "omaha/goopdate/worker_utils.h" | |
| 21 #include "omaha/goopdate/resource_manager.h" | |
| 22 #include "omaha/testing/unit_test.h" | |
| 23 | |
| 24 namespace omaha { | |
| 25 | |
| 26 namespace worker_utils { | |
| 27 | |
| 28 TEST(WorkerUtilsTest, FormatMessageForNetworkError) { | |
| 29 const TCHAR* const kEnglish = _T("en"); | |
| 30 EXPECT_SUCCEEDED(ResourceManager::Create( | |
| 31 false, app_util::GetCurrentModuleDirectory(), kEnglish)); | |
| 32 | |
| 33 const TCHAR* const kTestAppName = _T("Test App"); | |
| 34 CString message; | |
| 35 EXPECT_EQ(true, FormatMessageForNetworkError(GOOPDATE_E_NO_NETWORK, | |
| 36 kEnglish, | |
| 37 &message)); | |
| 38 EXPECT_STREQ( | |
| 39 _T("The installer could not connect to the Internet. Ensure that your ") | |
| 40 _T("computer is connected to the Internet and your firewall allows ") | |
| 41 _T("GoogleUpdate.exe to connect then try again."), | |
| 42 message); | |
| 43 | |
| 44 EXPECT_EQ(true, FormatMessageForNetworkError(GOOPDATE_E_NETWORK_UNAUTHORIZED, | |
| 45 kEnglish, | |
| 46 &message)); | |
| 47 EXPECT_STREQ( | |
| 48 _T("The installer could not connect to the Internet because of ") | |
| 49 _T("an HTTP 401 Unauthorized response. This is likely a proxy ") | |
| 50 _T("configuration issue. Please configure the proxy server to allow ") | |
| 51 _T("network access and try again or contact your network administrator."), | |
| 52 message); | |
| 53 | |
| 54 EXPECT_EQ(true, FormatMessageForNetworkError(GOOPDATE_E_NETWORK_FORBIDDEN, | |
| 55 kEnglish, | |
| 56 &message)); | |
| 57 EXPECT_STREQ( | |
| 58 _T("The installer could not connect to the Internet because of ") | |
| 59 _T("an HTTP 403 Forbidden response. This is likely a proxy ") | |
| 60 _T("configuration issue. Please configure the proxy server to allow ") | |
| 61 _T("network access and try again or contact your network administrator."), | |
| 62 message); | |
| 63 | |
| 64 EXPECT_EQ(true, | |
| 65 FormatMessageForNetworkError(GOOPDATE_E_NETWORK_PROXYAUTHREQUIRED, | |
| 66 kEnglish, | |
| 67 &message)); | |
| 68 EXPECT_STREQ( | |
| 69 _T("The installer could not connect to the Internet because a ") | |
| 70 _T("proxy server required user authentication. Please configure the ") | |
| 71 _T("proxy server to allow network access and try again or contact your ") | |
| 72 _T("network administrator."), | |
| 73 message); | |
| 74 | |
| 75 EXPECT_EQ(false, FormatMessageForNetworkError(E_FAIL, kEnglish, &message)); | |
| 76 EXPECT_STREQ( | |
| 77 _T("The installer could not connect to the Internet. Ensure that your ") | |
| 78 _T("computer is connected to the Internet and your firewall allows ") | |
| 79 _T("GoogleUpdate.exe to connect then try again."), | |
| 80 message); | |
| 81 | |
| 82 ResourceManager::Delete(); | |
| 83 } | |
| 84 | |
| 85 } // namespace job_controller_utils | |
| 86 | |
| 87 } // namespace omaha | |
| OLD | NEW |