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

Side by Side Diff: chrome/test/chromedriver/chrome_finder_unittest.cc

Issue 12848005: [chromedriver] Separate stuff of chrome from chromedriver. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments and fix compile error on mac. 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
« no previous file with comments | « chrome/test/chromedriver/chrome_finder_mac.mm ('k') | chrome/test/chromedriver/chrome_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012 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 <string>
6 #include <vector>
7
8 #include "base/bind.h"
9 #include "base/files/file_path.h"
10 #include "chrome/test/chromedriver/chrome_finder.h"
11 #include "testing/gtest/include/gtest/gtest.h"
12
13 namespace {
14
15 bool PathIn(const std::vector<base::FilePath>& list,
16 const base::FilePath& path) {
17 for (size_t i = 0; i < list.size(); ++i) {
18 if (list[i] == path)
19 return true;
20 }
21 return false;
22 }
23
24 void AssertFound(const base::FilePath& found,
25 const std::vector<base::FilePath>& existing_paths,
26 const std::vector<base::FilePath>& rel_paths,
27 const std::vector<base::FilePath>& locations) {
28 base::FilePath exe;
29 ASSERT_TRUE(internal::FindExe(
30 base::Bind(&PathIn, existing_paths),
31 rel_paths,
32 locations,
33 &exe));
34 ASSERT_EQ(found, exe);
35 }
36
37 } // namespace
38
39 TEST(ChromeFinderTest, FindExeFound) {
40 base::FilePath found =
41 base::FilePath().AppendASCII("exists").AppendASCII("exists");
42 std::vector<base::FilePath> existing_paths;
43 existing_paths.push_back(found);
44 std::vector<base::FilePath> rel_paths;
45 rel_paths.push_back(found.BaseName());
46 std::vector<base::FilePath> locations;
47 locations.push_back(found.DirName());
48 ASSERT_NO_FATAL_FAILURE(
49 AssertFound(found, existing_paths, rel_paths, locations));
50 }
51
52 TEST(ChromeFinderTest, FindExeShouldGoInOrder) {
53 base::FilePath dir(FILE_PATH_LITERAL("dir"));
54 base::FilePath first = dir.AppendASCII("first");
55 base::FilePath second = dir.AppendASCII("second");
56 std::vector<base::FilePath> existing_paths;
57 existing_paths.push_back(first);
58 existing_paths.push_back(second);
59 std::vector<base::FilePath> rel_paths;
60 rel_paths.push_back(first.BaseName());
61 rel_paths.push_back(second.BaseName());
62 std::vector<base::FilePath> locations;
63 locations.push_back(dir);
64 ASSERT_NO_FATAL_FAILURE(
65 AssertFound(first, existing_paths, rel_paths, locations));
66 }
67
68 TEST(ChromeFinderTest, FindExeShouldPreferExeNameOverDir) {
69 base::FilePath dir1(FILE_PATH_LITERAL("dir1"));
70 base::FilePath dir2(FILE_PATH_LITERAL("dir2"));
71 base::FilePath preferred(FILE_PATH_LITERAL("preferred"));
72 base::FilePath nonpreferred(FILE_PATH_LITERAL("nonpreferred"));
73 std::vector<base::FilePath> existing_paths;
74 existing_paths.push_back(dir2.Append(preferred));
75 existing_paths.push_back(dir1.Append(nonpreferred));
76 std::vector<base::FilePath> rel_paths;
77 rel_paths.push_back(preferred);
78 rel_paths.push_back(nonpreferred);
79 std::vector<base::FilePath> locations;
80 locations.push_back(dir1);
81 locations.push_back(dir2);
82 ASSERT_NO_FATAL_FAILURE(AssertFound(
83 dir2.Append(preferred), existing_paths, rel_paths, locations));
84 }
85
86 TEST(ChromeFinderTest, FindExeNotFound) {
87 base::FilePath found =
88 base::FilePath().AppendASCII("exists").AppendASCII("exists");
89 std::vector<base::FilePath> existing_paths;
90 std::vector<base::FilePath> rel_paths;
91 rel_paths.push_back(found.BaseName());
92 std::vector<base::FilePath> locations;
93 locations.push_back(found.DirName());
94 base::FilePath exe;
95 ASSERT_FALSE(internal::FindExe(
96 base::Bind(&PathIn, existing_paths),
97 rel_paths,
98 locations,
99 &exe));
100 }
101
102 TEST(ChromeFinderTest, NoCrash) {
103 // It's not worthwhile to check the validity of the path, so just check
104 // for crashes.
105 base::FilePath exe;
106 FindChrome(&exe);
107 }
OLDNEW
« no previous file with comments | « chrome/test/chromedriver/chrome_finder_mac.mm ('k') | chrome/test/chromedriver/chrome_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698