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

Side by Side Diff: chrome/browser/extensions/startup_helper_browsertest.cc

Issue 819133004: Make callers of CommandLine use it via the base:: namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 5 years, 12 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 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 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 <vector> 5 #include <vector>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "chrome/browser/extensions/startup_helper.h" 10 #include "chrome/browser/extensions/startup_helper.h"
11 #include "chrome/common/chrome_paths.h" 11 #include "chrome/common/chrome_paths.h"
12 #include "chrome/common/chrome_switches.h" 12 #include "chrome/common/chrome_switches.h"
13 #include "chrome/test/base/in_process_browser_test.h" 13 #include "chrome/test/base/in_process_browser_test.h"
14 14
15 class StartupHelperBrowserTest : public InProcessBrowserTest { 15 class StartupHelperBrowserTest : public InProcessBrowserTest {
16 public: 16 public:
17 StartupHelperBrowserTest() {} 17 StartupHelperBrowserTest() {}
18 ~StartupHelperBrowserTest() override {} 18 ~StartupHelperBrowserTest() override {}
19 19
20 void SetUpCommandLine(CommandLine* command_line) override { 20 void SetUpCommandLine(base::CommandLine* command_line) override {
21 command_line->AppendSwitch(switches::kNoStartupWindow); 21 command_line->AppendSwitch(switches::kNoStartupWindow);
22 PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir_); 22 PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir_);
23 test_data_dir_ = test_data_dir_.AppendASCII("extensions"); 23 test_data_dir_ = test_data_dir_.AppendASCII("extensions");
24 } 24 }
25 25
26 protected: 26 protected:
27 base::FilePath test_data_dir_; 27 base::FilePath test_data_dir_;
28 }; 28 };
29 29
30 IN_PROC_BROWSER_TEST_F(StartupHelperBrowserTest, ValidateCrx) { 30 IN_PROC_BROWSER_TEST_F(StartupHelperBrowserTest, ValidateCrx) {
31 // A list of crx file paths along with an expected result of valid (true) or 31 // A list of crx file paths along with an expected result of valid (true) or
32 // invalid (false). 32 // invalid (false).
33 std::vector<std::pair<base::FilePath, bool> > expectations; 33 std::vector<std::pair<base::FilePath, bool> > expectations;
34 expectations.push_back( 34 expectations.push_back(
35 std::make_pair(test_data_dir_.AppendASCII("good.crx"), true)); 35 std::make_pair(test_data_dir_.AppendASCII("good.crx"), true));
36 expectations.push_back( 36 expectations.push_back(
37 std::make_pair(test_data_dir_.AppendASCII("good2.crx"), true)); 37 std::make_pair(test_data_dir_.AppendASCII("good2.crx"), true));
38 expectations.push_back( 38 expectations.push_back(
39 std::make_pair(test_data_dir_.AppendASCII("bad_underscore.crx"), true)); 39 std::make_pair(test_data_dir_.AppendASCII("bad_underscore.crx"), true));
40 expectations.push_back( 40 expectations.push_back(
41 std::make_pair(test_data_dir_.AppendASCII("bad_magic.crx"), false)); 41 std::make_pair(test_data_dir_.AppendASCII("bad_magic.crx"), false));
42 42
43 for (std::vector<std::pair<base::FilePath, bool> >::iterator i = 43 for (std::vector<std::pair<base::FilePath, bool> >::iterator i =
44 expectations.begin(); 44 expectations.begin();
45 i != expectations.end(); ++i) { 45 i != expectations.end(); ++i) {
46 CommandLine command_line(CommandLine::NO_PROGRAM); 46 base::CommandLine command_line(base::CommandLine::NO_PROGRAM);
47 const base::FilePath& path = i->first; 47 const base::FilePath& path = i->first;
48 command_line.AppendSwitchPath(switches::kValidateCrx, path); 48 command_line.AppendSwitchPath(switches::kValidateCrx, path);
49 49
50 std::string error; 50 std::string error;
51 extensions::StartupHelper helper; 51 extensions::StartupHelper helper;
52 bool result = helper.ValidateCrx(command_line, &error); 52 bool result = helper.ValidateCrx(command_line, &error);
53 if (i->second) { 53 if (i->second) {
54 EXPECT_TRUE(result) << path.LossyDisplayName() 54 EXPECT_TRUE(result) << path.LossyDisplayName()
55 << " expected to be valid but wasn't"; 55 << " expected to be valid but wasn't";
56 } else { 56 } else {
57 EXPECT_FALSE(result) << path.LossyDisplayName() 57 EXPECT_FALSE(result) << path.LossyDisplayName()
58 << " expected to be invalid but wasn't"; 58 << " expected to be invalid but wasn't";
59 EXPECT_FALSE(error.empty()) << "Error message wasn't set for " 59 EXPECT_FALSE(error.empty()) << "Error message wasn't set for "
60 << path.LossyDisplayName(); 60 << path.LossyDisplayName();
61 } 61 }
62 } 62 }
63 } 63 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/startup_helper.cc ('k') | chrome/browser/extensions/test_extension_environment.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698