OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
8 #include "chrome/browser/extensions/webstore_installer.h" | 8 #include "chrome/browser/extensions/webstore_installer.h" |
9 #include "chrome/browser/omaha_client/chrome_omaha_query_params_delegate.h" | 9 #include "chrome/browser/update_client/chrome_update_query_params_delegate.h" |
10 #include "components/crx_file/id_util.h" | 10 #include "components/crx_file/id_util.h" |
11 #include "components/omaha_client/omaha_query_params.h" | 11 #include "components/update_client/update_query_params.h" |
12 #include "net/base/escape.h" | 12 #include "net/base/escape.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
14 | 14 |
15 using base::StringPrintf; | 15 using base::StringPrintf; |
16 using omaha_client::OmahaQueryParams; | 16 using update_client::UpdateQueryParams; |
17 | 17 |
18 namespace extensions { | 18 namespace extensions { |
19 | 19 |
20 // Returns true if |target| is found in |source|. | 20 // Returns true if |target| is found in |source|. |
21 bool Contains(const std::string& source, const std::string& target) { | 21 bool Contains(const std::string& source, const std::string& target) { |
22 return source.find(target) != std::string::npos; | 22 return source.find(target) != std::string::npos; |
23 } | 23 } |
24 | 24 |
25 TEST(WebstoreInstallerTest, PlatformParams) { | 25 TEST(WebstoreInstallerTest, PlatformParams) { |
26 std::string id = crx_file::id_util::GenerateId("some random string"); | 26 std::string id = crx_file::id_util::GenerateId("some random string"); |
27 std::string source = "inline"; | 27 std::string source = "inline"; |
28 GURL url = WebstoreInstaller::GetWebstoreInstallURL(id, | 28 GURL url = WebstoreInstaller::GetWebstoreInstallURL(id, |
29 WebstoreInstaller::INSTALL_SOURCE_INLINE); | 29 WebstoreInstaller::INSTALL_SOURCE_INLINE); |
30 std::string query = url.query(); | 30 std::string query = url.query(); |
31 EXPECT_TRUE( | 31 EXPECT_TRUE( |
32 Contains(query, StringPrintf("os=%s", OmahaQueryParams::GetOS()))); | 32 Contains(query, StringPrintf("os=%s", UpdateQueryParams::GetOS()))); |
33 EXPECT_TRUE( | 33 EXPECT_TRUE( |
34 Contains(query, StringPrintf("arch=%s", OmahaQueryParams::GetArch()))); | 34 Contains(query, StringPrintf("arch=%s", UpdateQueryParams::GetArch()))); |
35 EXPECT_TRUE(Contains( | 35 EXPECT_TRUE(Contains( |
36 query, StringPrintf("nacl_arch=%s", OmahaQueryParams::GetNaclArch()))); | 36 query, StringPrintf("nacl_arch=%s", UpdateQueryParams::GetNaclArch()))); |
37 EXPECT_TRUE( | 37 EXPECT_TRUE( |
38 Contains(query, | 38 Contains(query, |
39 net::EscapeQueryParamValue( | 39 net::EscapeQueryParamValue( |
40 StringPrintf("installsource=%s", source.c_str()), true))); | 40 StringPrintf("installsource=%s", source.c_str()), true))); |
41 EXPECT_TRUE(Contains( | 41 EXPECT_TRUE(Contains( |
42 query, | 42 query, |
43 StringPrintf("lang=%s", ChromeOmahaQueryParamsDelegate::GetLang()))); | 43 StringPrintf("lang=%s", ChromeUpdateQueryParamsDelegate::GetLang()))); |
44 } | 44 } |
45 | 45 |
46 } // namespace extensions | 46 } // namespace extensions |
OLD | NEW |