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
3 // found in the LICENSE file.
5 #include "chrome/browser/omaha_query_params/omaha_query_params.h"
7 #include "base/strings/stringprintf.h"
8 #include "chrome/common/chrome_version_info.h"
9 #include "testing/gtest/include/gtest/gtest.h"
11 using base::StringPrintf
;
15 bool Contains(const std::string
& source
, const std::string
& target
) {
16 return source
.find(target
) != std::string::npos
;
19 void TestParams(OmahaQueryParams::ProdId prod_id
) {
20 std::string params
= OmahaQueryParams::Get(prod_id
);
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.
27 Contains(params
, StringPrintf("os=%s", OmahaQueryParams::GetOS())));
29 Contains(params
, StringPrintf("arch=%s", OmahaQueryParams::GetArch())));
32 StringPrintf("prod=%s", OmahaQueryParams::GetProdIdString(prod_id
))));
35 StringPrintf("prodchannel=%s", OmahaQueryParams::GetChannelString())));
38 StringPrintf("prodversion=%s", chrome::VersionInfo().Version().c_str())));
41 StringPrintf("lang=%s", OmahaQueryParams::GetLang())));
44 TEST(OmahaQueryParams
, GetOmahaQueryParams
) {
45 TestParams(OmahaQueryParams::CRX
);
46 TestParams(OmahaQueryParams::CHROME
);