| 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 "base/strings/stringprintf.h" | 5 #include "base/strings/stringprintf.h" |
| 6 #include "components/omaha_query_params/omaha_query_params.h" | 6 #include "components/omaha_query_params/omaha_query_params.h" |
| 7 #include "components/omaha_query_params/omaha_query_params_delegate.h" | 7 #include "components/omaha_query_params/omaha_query_params_delegate.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 | 9 |
| 10 using base::StringPrintf; | 10 using base::StringPrintf; |
| 11 | 11 |
| 12 namespace omaha_query_params { | 12 namespace omaha_query_params { |
| 13 | 13 |
| 14 namespace { | 14 namespace { |
| 15 | 15 |
| 16 bool Contains(const std::string& source, const std::string& target) { | 16 bool Contains(const std::string& source, const std::string& target) { |
| 17 return source.find(target) != std::string::npos; | 17 return source.find(target) != std::string::npos; |
| 18 } | 18 } |
| 19 | 19 |
| 20 class TestOmahaQueryParamsDelegate : public OmahaQueryParamsDelegate { | 20 class TestOmahaQueryParamsDelegate : public OmahaQueryParamsDelegate { |
| 21 virtual std::string GetExtraParams() override { return "&cat=dog"; } | 21 std::string GetExtraParams() override { return "&cat=dog"; } |
| 22 }; | 22 }; |
| 23 | 23 |
| 24 } // namespace | 24 } // namespace |
| 25 | 25 |
| 26 void TestParams(OmahaQueryParams::ProdId prod_id, bool extra_params) { | 26 void TestParams(OmahaQueryParams::ProdId prod_id, bool extra_params) { |
| 27 std::string params = OmahaQueryParams::Get(prod_id); | 27 std::string params = OmahaQueryParams::Get(prod_id); |
| 28 | 28 |
| 29 // This doesn't so much test what the values are (since that would be an | 29 // This doesn't so much test what the values are (since that would be an |
| 30 // almost exact duplication of code with omaha_query_params.cc, and wouldn't | 30 // almost exact duplication of code with omaha_query_params.cc, and wouldn't |
| 31 // really test anything) as it is a verification that all the params are | 31 // really test anything) as it is a verification that all the params are |
| (...skipping 14 matching lines...) Expand all Loading... |
| 46 TestParams(OmahaQueryParams::CHROME, false); | 46 TestParams(OmahaQueryParams::CHROME, false); |
| 47 | 47 |
| 48 TestOmahaQueryParamsDelegate delegate; | 48 TestOmahaQueryParamsDelegate delegate; |
| 49 OmahaQueryParams::SetDelegate(&delegate); | 49 OmahaQueryParams::SetDelegate(&delegate); |
| 50 | 50 |
| 51 TestParams(OmahaQueryParams::CRX, true); | 51 TestParams(OmahaQueryParams::CRX, true); |
| 52 TestParams(OmahaQueryParams::CHROME, true); | 52 TestParams(OmahaQueryParams::CHROME, true); |
| 53 } | 53 } |
| 54 | 54 |
| 55 } // namespace omaha_query_params | 55 } // namespace omaha_query_params |
| OLD | NEW |