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

Unified Diff: chrome_frame/chrome_launcher_unittest.cc

Issue 218019: Initial import of the Chrome Frame codebase. Integration in chrome.gyp coming... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 11 years, 3 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 | « chrome_frame/chrome_launcher_main.cc ('k') | chrome_frame/chrome_protocol.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome_frame/chrome_launcher_unittest.cc
===================================================================
--- chrome_frame/chrome_launcher_unittest.cc (revision 0)
+++ chrome_frame/chrome_launcher_unittest.cc (revision 0)
@@ -0,0 +1,49 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/command_line.h"
+#include "base/logging.h"
+#include "chrome/common/chrome_switches.h"
+#include "chrome_frame/chrome_launcher.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace {
+
+// Utility class to disable logging. Required to disable DCHECKs that some
+// of our tests would otherwise trigger.
+class LogDisabler {
+ public:
+ LogDisabler() {
+ initial_log_level_ = logging::GetMinLogLevel();
+ logging::SetMinLogLevel(logging::LOG_FATAL + 1);
+ }
+
+ ~LogDisabler() {
+ logging::SetMinLogLevel(initial_log_level_);
+ }
+
+ private:
+ int initial_log_level_;
+};
+
+} // namespace
+
+TEST(ChromeLauncher, SanitizeCommandLine) {
+ CommandLine bad(L"dummy.exe");
+ bad.AppendSwitch(switches::kDisableMetrics); // in whitelist
+ bad.AppendSwitchWithValue(switches::kLoadExtension, L"foo"); // in whitelist
+ bad.AppendSwitch(L"no-such-switch"); // does not exist
+ bad.AppendSwitch(switches::kHomePage); // exists but not in whitelist
+
+ LogDisabler no_dchecks;
+
+ CommandLine sanitized(L"dumbo.exe");
+ chrome_launcher::SanitizeCommandLine(bad, &sanitized);
+ EXPECT_TRUE(sanitized.HasSwitch(switches::kDisableMetrics));
+ EXPECT_TRUE(sanitized.HasSwitch(switches::kLoadExtension));
+ EXPECT_FALSE(sanitized.HasSwitch(L"no-such-switch"));
+ EXPECT_FALSE(sanitized.HasSwitch(switches::kHomePage));
+
+ EXPECT_EQ(sanitized.GetSwitchValue(switches::kLoadExtension), L"foo");
+}
« no previous file with comments | « chrome_frame/chrome_launcher_main.cc ('k') | chrome_frame/chrome_protocol.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698