OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/files/file_path.h" | 6 #include "base/file_util.h" |
7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
8 #include "base/process/launch.h" | 8 #include "base/process/launch.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
11 | 11 |
12 base::FilePath GinShellPath() { | 12 base::FilePath GinShellPath() { |
13 base::FilePath dir; | 13 base::FilePath dir; |
14 PathService::Get(base::DIR_EXE, &dir); | 14 PathService::Get(base::DIR_EXE, &dir); |
15 return dir.AppendASCII("gin_shell"); | 15 return dir.AppendASCII("gin_shell"); |
16 } | 16 } |
17 | 17 |
18 base::FilePath HelloWorldPath() { | 18 base::FilePath HelloWorldPath() { |
19 base::FilePath path; | 19 base::FilePath path; |
20 PathService::Get(base::DIR_SOURCE_ROOT, &path); | 20 PathService::Get(base::DIR_SOURCE_ROOT, &path); |
21 return path | 21 return path |
22 .AppendASCII("gin") | 22 .AppendASCII("gin") |
23 .AppendASCII("shell") | 23 .AppendASCII("shell") |
24 .AppendASCII("hello_world.js"); | 24 .AppendASCII("hello_world.js"); |
25 } | 25 } |
26 | 26 |
27 TEST(GinShellTest, HelloWorld) { | 27 TEST(GinShellTest, HelloWorld) { |
28 CommandLine cmd(GinShellPath()); | 28 base::FilePath ginShellPath(GinShellPath()); |
abarth-chromium
2014/08/13 18:00:16
gin_shell_path?
hansmuller
2014/08/13 19:22:14
Yes, sorry about that. I've been writing a lot of
| |
29 cmd.AppendArgPath(HelloWorldPath()); | 29 base::FilePath helloWorldPath(HelloWorldPath()); |
30 ASSERT_TRUE(base::PathExists(ginShellPath)); | |
31 ASSERT_TRUE(base::PathExists(helloWorldPath)); | |
32 | |
33 CommandLine cmd(ginShellPath); | |
34 cmd.AppendArgPath(helloWorldPath); | |
30 std::string output; | 35 std::string output; |
31 ASSERT_TRUE(base::GetAppOutput(cmd, &output)); | 36 ASSERT_TRUE(base::GetAppOutput(cmd, &output)); |
32 base::TrimWhitespaceASCII(output, base::TRIM_ALL, &output); | 37 base::TrimWhitespaceASCII(output, base::TRIM_ALL, &output); |
33 ASSERT_EQ("Hello World", output); | 38 ASSERT_EQ("Hello World", output); |
34 } | 39 } |
OLD | NEW |