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

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

Issue 12660017: Add a commandline flag to chrome to validate crx files (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: added browser test Created 7 years, 9 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 | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include <vector>
6
7 #include "base/command_line.h"
8 #include "base/files/file_path.h"
9 #include "base/path_service.h"
10 #include "chrome/browser/extensions/startup_helper.h"
11 #include "chrome/common/chrome_paths.h"
12 #include "chrome/common/chrome_switches.h"
13 #include "chrome/test/base/in_process_browser_test.h"
14
15 class StartupHelperBrowserTest : public InProcessBrowserTest {
16 public:
17 StartupHelperBrowserTest() {}
18 virtual ~StartupHelperBrowserTest() {}
19
20 virtual void SetUpCommandLine(CommandLine* command_line) {
21 command_line->AppendSwitch(switches::kNoStartupWindow);
22 PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir_);
23 test_data_dir_ = test_data_dir_.AppendASCII("extensions");
24 }
25
26 protected:
27 base::FilePath test_data_dir_;
28 };
29
30 IN_PROC_BROWSER_TEST_F(StartupHelperBrowserTest, ValidateCrx) {
31 // A list of crx file paths along with an expected result of valid (true) or
32 // invalid (false).
33 std::vector<std::pair<base::FilePath, bool> > expectations;
34 expectations.push_back(
35 std::make_pair(test_data_dir_.AppendASCII("good.crx"), true));
36 expectations.push_back(
37 std::make_pair(test_data_dir_.AppendASCII("good2.crx"), true));
38 expectations.push_back(
39 std::make_pair(test_data_dir_.AppendASCII("bad_magic.crx"), false));
40 expectations.push_back(
41 std::make_pair(test_data_dir_.AppendASCII("bad_underscore.crx"), false));
42
43 for (std::vector<std::pair<base::FilePath, bool> >::iterator i =
44 expectations.begin();
45 i != expectations.end(); ++i) {
46 CommandLine command_line(CommandLine::NO_PROGRAM);
47 const base::FilePath& path = i->first;
48 command_line.AppendSwitchPath(switches::kValidateCrx, path);
49
50 extensions::StartupHelper helper;
51 bool result = helper.ValidateCrx(command_line);
52 if (i->second)
53 EXPECT_TRUE(result) << path.LossyDisplayName()
54 << " expected to be valid but wasn't";
55 else
56 EXPECT_FALSE(result) << path.LossyDisplayName()
57 << " expected to be invalid but wasn't";
58 }
59 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698