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

Side by Side Diff: common/webplugin_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 | « common/webplugin_utils.cc ('k') | common/xml_const.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 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/error.h"
18 #include "omaha/base/file.h"
19 #include "omaha/base/path.h"
20 #include "omaha/base/utils.h"
21 #include "omaha/common/webplugin_utils.h"
22 #include "omaha/testing/unit_test.h"
23
24 namespace omaha {
25
26 namespace webplugin_utils {
27
28 #define YOUTUBEUPLOADEREN_TAG \
29 _T("\"appguid={A4F7B07B-B9BD-4a33-B136-96D2ADFB60CB}&") \
30 _T("appname=YouTubeUploader&needsadmin=False&lang=en\"")
31
32
33 TEST(WebPluginUtilsTest, BuildOneClickRequestString_NullOutParam) {
34 CommandLineArgs args;
35 EXPECT_EQ(E_INVALIDARG, BuildOneClickRequestString(args, NULL));
36 }
37
38 TEST(WebPluginUtilsTest, BuildOneClickRequestString_WrongArgs) {
39 CommandLineArgs args;
40 CString request;
41 EXPECT_EQ(E_UNEXPECTED, BuildOneClickRequestString(args, &request));
42 }
43
44 TEST(WebPluginUtilsTest, BuildOneClickRequestString_NoUrlDomain) {
45 CommandLineArgs args;
46 CString request;
47
48 args.mode = COMMANDLINE_MODE_WEBPLUGIN;
49 EXPECT_EQ(E_UNEXPECTED, BuildOneClickRequestString(args, &request));
50 }
51
52 TEST(WebPluginUtilsTest, BuildOneClickRequestString_Valid) {
53 CommandLineArgs args;
54 CString request;
55
56 args.mode = COMMANDLINE_MODE_WEBPLUGIN;
57 args.webplugin_urldomain = _T("http://www.google.com/");
58 args.webplugin_args = _T("/install \"appguid=")
59 _T("{8A69D345-D564-463c-AFF1-A69D9E530F96}")
60 _T("&appname=Google Chrome&needsadmin=true&lang=en\"");
61 EXPECT_EQ(S_OK, BuildOneClickRequestString(args, &request));
62
63 EXPECT_STREQ(_T("?du=http://www.google.com/&args=/install%20")
64 _T("%22appguid=%7B8A69D345-D564-463c-AFF1-A69D9E530F96")
65 _T("%7D%26appname=Google%20Chrome%26needsadmin=true%26")
66 _T("lang=en%22"),
67 request);
68 }
69
70 TEST(WebPluginUtilsTest, BuildOneClickWorkerArgs_Valid) {
71 CommandLineArgs args;
72 CString oneclick_args;
73
74 args.install_source = _T("oneclick");
75 args.webplugin_args = _T("/install \"appguid=")
76 _T("{8A69D345-D564-463c-AFF1-A69D9E530F96}")
77 _T("&appname=Google Chrome&needsadmin=true&lang=en\"");
78 EXPECT_EQ(S_OK, BuildOneClickWorkerArgs(args, &oneclick_args));
79
80 EXPECT_STREQ(_T("/install ")
81 _T("\"appguid={8A69D345-D564-463c-AFF1-A69D9E530F96}")
82 _T("&appname=Google Chrome&needsadmin=true&lang=en\" ")
83 _T("/installsource oneclick"),
84 oneclick_args);
85 }
86
87 // This tests valid command line args that are not valid to be sent through
88 // to google_update.exe (e.g. /install).
89 TEST(WebPluginUtilsTest, BuildOneClickWorkerArgs_Invalid) {
90 CommandLineArgs args;
91 CString oneclick_args;
92
93 args.install_source = _T("oneclick");
94
95 args.webplugin_args = _T("/handoff ") YOUTUBEUPLOADEREN_TAG;
96 EXPECT_EQ(E_INVALIDARG, BuildOneClickWorkerArgs(args, &oneclick_args));
97
98 args.webplugin_args = _T("/regserver");
99 EXPECT_EQ(E_INVALIDARG, BuildOneClickWorkerArgs(args, &oneclick_args));
100
101 args.webplugin_args = _T("/unregserver");
102 EXPECT_EQ(E_INVALIDARG, BuildOneClickWorkerArgs(args, &oneclick_args));
103
104 args.webplugin_args = _T("/install ") YOUTUBEUPLOADEREN_TAG _T(" /silent");
105 EXPECT_EQ(E_INVALIDARG, BuildOneClickWorkerArgs(args, &oneclick_args));
106 }
107
108 TEST(WebPluginUtilsTest, CopyGoopdateToTempDir) {
109 CPath current_goopdate_path(app_util::GetCurrentModuleDirectory());
110 current_goopdate_path.Append(_T("unittest_support\\omaha_1.3.x\\"));
111 CPath goopdate_temp_path;
112 ASSERT_SUCCEEDED(CopyGoopdateToTempDir(current_goopdate_path,
113 &goopdate_temp_path));
114
115 std::vector<CString> files;
116 EXPECT_HRESULT_SUCCEEDED(FindFilesEx(goopdate_temp_path, _T("*.*"), &files));
117
118 EXPECT_EQ(3, files.size());
119
120 std::map<CString, int> files_map;
121 for (size_t file_index = 0; file_index < files.size(); ++file_index) {
122 files_map[files[file_index]] = 1;
123 }
124
125 EXPECT_TRUE(files_map.find(_T("GoogleUpdate.exe")) != files_map.end());
126 EXPECT_TRUE(files_map.find(_T("goopdate.dll")) != files_map.end());
127 EXPECT_TRUE(files_map.find(_T("goopdateres_en.dll")) != files_map.end());
128
129 EXPECT_HRESULT_SUCCEEDED(DeleteDirectory(goopdate_temp_path));
130 }
131
132 TEST(WebPluginUtilsTest, IsLanguageSupported_InvalidArgs) {
133 CString args = _T("/en");
134 EXPECT_FAILED(IsLanguageSupported(args));
135 }
136
137 TEST(WebPluginUtilsTest, IsLanguageSupported_LangOK) {
138 CString args = _T("/install \"appguid=")
139 _T("{8A69D345-D564-463c-AFF1-A69D9E530F96}")
140 _T("&appname=Google Chrome&needsadmin=true&lang=en\"");
141 EXPECT_SUCCEEDED(IsLanguageSupported(args));
142 }
143
144 TEST(WebPluginUtilsTest, IsLanguageSupported_LangNotFound) {
145 CString args = _T("/install \"appguid=")
146 _T("{8A69D345-D564-463c-AFF1-A69D9E530F96}")
147 _T("&appname=Google Chrome&needsadmin=true&lang=zz\"");
148
149 EXPECT_EQ(GOOPDATE_E_ONECLICK_LANGUAGE_NOT_SUPPORTED,
150 IsLanguageSupported(args));
151 }
152
153 } // namespace webplugin_utils
154
155 } // namespace omaha
156
OLDNEW
« no previous file with comments | « common/webplugin_utils.cc ('k') | common/xml_const.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698