Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(671)

Unified Diff: components/omaha_query_params/omaha_query_params_unittest.cc

Issue 333353005: Move OmahaQueryParams to a component and add a delegate interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/omaha_query_params/omaha_query_params_delegate.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/omaha_query_params/omaha_query_params_unittest.cc
diff --git a/chrome/browser/omaha_query_params/omaha_query_params_unittest.cc b/components/omaha_query_params/omaha_query_params_unittest.cc
similarity index 55%
rename from chrome/browser/omaha_query_params/omaha_query_params_unittest.cc
rename to components/omaha_query_params/omaha_query_params_unittest.cc
index e8a736aea300f7aabd1d7b11b1b791037f0b6c58..37a97e919dd1f8c22186f4c2b696e4198dbcc0c6 100644
--- a/chrome/browser/omaha_query_params/omaha_query_params_unittest.cc
+++ b/components/omaha_query_params/omaha_query_params_unittest.cc
@@ -2,21 +2,28 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/omaha_query_params/omaha_query_params.h"
-
#include "base/strings/stringprintf.h"
-#include "chrome/common/chrome_version_info.h"
+#include "components/omaha_query_params/omaha_query_params.h"
+#include "components/omaha_query_params/omaha_query_params_delegate.h"
#include "testing/gtest/include/gtest/gtest.h"
using base::StringPrintf;
-namespace chrome {
+namespace omaha_query_params {
+
+namespace {
bool Contains(const std::string& source, const std::string& target) {
return source.find(target) != std::string::npos;
}
-void TestParams(OmahaQueryParams::ProdId prod_id) {
+class TestOmahaQueryParamsDelegate : public OmahaQueryParamsDelegate {
+ virtual std::string GetExtraParams() OVERRIDE { return "&cat=dog"; }
+};
+
+} // namespace
+
+void TestParams(OmahaQueryParams::ProdId prod_id, bool extra_params) {
std::string params = OmahaQueryParams::Get(prod_id);
// This doesn't so much test what the values are (since that would be an
@@ -30,20 +37,19 @@ void TestParams(OmahaQueryParams::ProdId prod_id) {
EXPECT_TRUE(Contains(
params,
StringPrintf("prod=%s", OmahaQueryParams::GetProdIdString(prod_id))));
- EXPECT_TRUE(Contains(
- params,
- StringPrintf("prodchannel=%s", OmahaQueryParams::GetChannelString())));
- EXPECT_TRUE(Contains(
- params,
- StringPrintf("prodversion=%s", chrome::VersionInfo().Version().c_str())));
- EXPECT_TRUE(Contains(
- params,
- StringPrintf("lang=%s", OmahaQueryParams::GetLang())));
+ if (extra_params)
+ EXPECT_TRUE(Contains(params, "cat=dog"));
}
-TEST(OmahaQueryParams, GetOmahaQueryParams) {
- TestParams(OmahaQueryParams::CRX);
- TestParams(OmahaQueryParams::CHROME);
+TEST(OmahaQueryParamsTest, GetParams) {
+ TestParams(OmahaQueryParams::CRX, false);
+ TestParams(OmahaQueryParams::CHROME, false);
+
+ TestOmahaQueryParamsDelegate delegate;
+ OmahaQueryParams::SetDelegate(&delegate);
+
+ TestParams(OmahaQueryParams::CRX, true);
+ TestParams(OmahaQueryParams::CHROME, true);
}
-} // namespace chrome
+} // namespace omaha_query_params
« no previous file with comments | « components/omaha_query_params/omaha_query_params_delegate.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698