OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/omaha_query_params/omaha_query_params.h" | |
6 | |
7 #include "base/strings/stringprintf.h" | 5 #include "base/strings/stringprintf.h" |
| 6 #include "chrome/browser/omaha_query_params/chrome_omaha_query_params_delegate.h
" |
8 #include "chrome/common/chrome_version_info.h" | 7 #include "chrome/common/chrome_version_info.h" |
| 8 #include "components/omaha_query_params/omaha_query_params.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
11 using base::StringPrintf; | 11 using base::StringPrintf; |
12 | 12 |
13 namespace chrome { | 13 namespace { |
14 | 14 |
15 bool Contains(const std::string& source, const std::string& target) { | 15 bool Contains(const std::string& source, const std::string& target) { |
16 return source.find(target) != std::string::npos; | 16 return source.find(target) != std::string::npos; |
17 } | 17 } |
18 | 18 |
| 19 } // namespace |
| 20 |
19 void TestParams(OmahaQueryParams::ProdId prod_id) { | 21 void TestParams(OmahaQueryParams::ProdId prod_id) { |
20 std::string params = OmahaQueryParams::Get(prod_id); | 22 std::string params = OmahaQueryParams::Get(prod_id); |
21 | 23 |
22 // This doesn't so much test what the values are (since that would be an | |
23 // almost exact duplication of code with omaha_query_params.cc, and wouldn't | |
24 // really test anything) as it is a verification that all the params are | |
25 // present in the generated string. | |
26 EXPECT_TRUE( | 24 EXPECT_TRUE( |
27 Contains(params, StringPrintf("os=%s", OmahaQueryParams::GetOS()))); | 25 Contains(params, StringPrintf("os=%s", OmahaQueryParams::GetOS()))); |
28 EXPECT_TRUE( | 26 EXPECT_TRUE( |
29 Contains(params, StringPrintf("arch=%s", OmahaQueryParams::GetArch()))); | 27 Contains(params, StringPrintf("arch=%s", OmahaQueryParams::GetArch()))); |
30 EXPECT_TRUE(Contains( | 28 EXPECT_TRUE(Contains( |
31 params, | 29 params, |
32 StringPrintf("prod=%s", OmahaQueryParams::GetProdIdString(prod_id)))); | 30 StringPrintf("prod=%s", OmahaQueryParams::GetProdIdString(prod_id)))); |
33 EXPECT_TRUE(Contains( | 31 EXPECT_TRUE(Contains( |
34 params, | 32 params, |
35 StringPrintf("prodchannel=%s", OmahaQueryParams::GetChannelString()))); | 33 StringPrintf("prodchannel=%s", |
| 34 ChromeOmahaQueryParamsDelegate::GetChannelString()))); |
36 EXPECT_TRUE(Contains( | 35 EXPECT_TRUE(Contains( |
37 params, | 36 params, |
38 StringPrintf("prodversion=%s", chrome::VersionInfo().Version().c_str()))); | 37 StringPrintf("prodversion=%s", chrome::VersionInfo().Version().c_str()))); |
39 EXPECT_TRUE(Contains( | 38 EXPECT_TRUE(Contains( |
40 params, | 39 params, |
41 StringPrintf("lang=%s", OmahaQueryParams::GetLang()))); | 40 StringPrintf("lang=%s", ChromeOmahaQueryParamsDelegate::GetLang()))); |
42 } | 41 } |
43 | 42 |
44 TEST(OmahaQueryParams, GetOmahaQueryParams) { | 43 TEST(ChromeOmahaQueryParamsDelegateTest, GetParams) { |
45 TestParams(OmahaQueryParams::CRX); | 44 TestParams(OmahaQueryParams::CRX); |
46 TestParams(OmahaQueryParams::CHROME); | 45 TestParams(OmahaQueryParams::CHROME); |
47 } | 46 } |
48 | |
49 } // namespace chrome | |
OLD | NEW |