| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "blimp/engine/app/blimp_engine_config.h" | 5 #include "blimp/engine/app/blimp_engine_config.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 for (const std::string& filepath_switch : filepath_switches) { | 51 for (const std::string& filepath_switch : filepath_switches) { |
| 52 cmd_vec.push_back(base::StringPrintf( | 52 cmd_vec.push_back(base::StringPrintf( |
| 53 "--%s=%s", filepath_switch.c_str(), | 53 "--%s=%s", filepath_switch.c_str(), |
| 54 GetFilepathForSwitch(filepath_switch).AsUTF8Unsafe().c_str())); | 54 GetFilepathForSwitch(filepath_switch).AsUTF8Unsafe().c_str())); |
| 55 } | 55 } |
| 56 return base::CommandLine(cmd_vec); | 56 return base::CommandLine(cmd_vec); |
| 57 } | 57 } |
| 58 | 58 |
| 59 base::FilePath GetFilepathForSwitch( | 59 base::FilePath GetFilepathForSwitch( |
| 60 const std::string& filepath_switch) const { | 60 const std::string& filepath_switch) const { |
| 61 return temp_dir_.path().Append(filepath_switch); | 61 return temp_dir_.GetPath().Append(filepath_switch); |
| 62 } | 62 } |
| 63 | 63 |
| 64 const std::vector<std::string> all_filepath_switches_ = { | 64 const std::vector<std::string> all_filepath_switches_ = { |
| 65 kClientAuthTokenPath}; | 65 kClientAuthTokenPath}; |
| 66 | 66 |
| 67 base::ScopedTempDir temp_dir_; | 67 base::ScopedTempDir temp_dir_; |
| 68 }; | 68 }; |
| 69 | 69 |
| 70 TEST_F(BlimpEngineConfigTest, ClientAuthTokenCorrect) { | 70 TEST_F(BlimpEngineConfigTest, ClientAuthTokenCorrect) { |
| 71 auto cmd_line = CreateCommandLine(all_filepath_switches_); | 71 auto cmd_line = CreateCommandLine(all_filepath_switches_); |
| 72 auto engine_config = BlimpEngineConfig::Create(cmd_line); | 72 auto engine_config = BlimpEngineConfig::Create(cmd_line); |
| 73 EXPECT_NE(nullptr, engine_config); | 73 EXPECT_NE(nullptr, engine_config); |
| 74 EXPECT_EQ(kTestClientAuthToken, engine_config->client_auth_token()); | 74 EXPECT_EQ(kTestClientAuthToken, engine_config->client_auth_token()); |
| 75 } | 75 } |
| 76 | 76 |
| 77 TEST_F(BlimpEngineConfigTest, ClientAuthTokenEmpty) { | 77 TEST_F(BlimpEngineConfigTest, ClientAuthTokenEmpty) { |
| 78 RemoveFileForSwitch(kClientAuthTokenPath); | 78 RemoveFileForSwitch(kClientAuthTokenPath); |
| 79 CreateFileForSwitch(kClientAuthTokenPath, " "); | 79 CreateFileForSwitch(kClientAuthTokenPath, " "); |
| 80 auto cmd_line = CreateCommandLine(all_filepath_switches_); | 80 auto cmd_line = CreateCommandLine(all_filepath_switches_); |
| 81 auto engine_config = BlimpEngineConfig::Create(cmd_line); | 81 auto engine_config = BlimpEngineConfig::Create(cmd_line); |
| 82 EXPECT_EQ(nullptr, engine_config); | 82 EXPECT_EQ(nullptr, engine_config); |
| 83 } | 83 } |
| 84 | 84 |
| 85 } // namespace | 85 } // namespace |
| 86 } // namespace engine | 86 } // namespace engine |
| 87 } // namespace blimp | 87 } // namespace blimp |
| OLD | NEW |