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