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

Side by Side Diff: blimp/engine/app/blimp_engine_config_unittest.cc

Issue 2281783002: Changes client_token to be client_auth_token. (Closed)
Patch Set: Linting. Created 4 years, 3 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 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
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/files/file_util.h" 12 #include "base/files/file_util.h"
13 #include "base/files/scoped_temp_dir.h" 13 #include "base/files/scoped_temp_dir.h"
14 #include "base/strings/stringprintf.h" 14 #include "base/strings/stringprintf.h"
15 #include "blimp/common/switches.h" 15 #include "blimp/common/switches.h"
16 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
17 17
18 namespace blimp { 18 namespace blimp {
19 namespace engine { 19 namespace engine {
20 namespace { 20 namespace {
21 21
22 // Reference client token. 22 // Reference client token.
23 static const char kTestClientToken[] = "Reference client token"; 23 static const char kTestClientAuthToken[] = "Reference client token";
24 24
25 class BlimpEngineConfigTest : public testing::Test { 25 class BlimpEngineConfigTest : public testing::Test {
26 protected: 26 protected:
27 void SetUp() override { 27 void SetUp() override {
28 // Create a temporary directory and populate it with all of the switches 28 // Create a temporary directory and populate it with all of the switches
29 // If a test requires a switch's file to be missing, call 29 // If a test requires a switch's file to be missing, call
30 // RemoveFileForSwitch(). 30 // RemoveFileForSwitch().
31 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 31 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
32 CreateFileForSwitch(kClientTokenPath, kTestClientToken); 32 CreateFileForSwitch(kClientAuthTokenPath, kTestClientAuthToken);
33 } 33 }
34 34
35 // Creates a file in the temp directory for a given filepath switch. 35 // Creates a file in the temp directory for a given filepath switch.
36 void CreateFileForSwitch(const std::string& filepath_switch, 36 void CreateFileForSwitch(const std::string& filepath_switch,
37 const std::string& data) const { 37 const std::string& data) const {
38 ASSERT_TRUE(base::WriteFile(GetFilepathForSwitch(filepath_switch), 38 ASSERT_TRUE(base::WriteFile(GetFilepathForSwitch(filepath_switch),
39 data.c_str(), data.size())); 39 data.c_str(), data.size()));
40 } 40 }
41 41
42 // Removes the associated file for a given filepath switch. 42 // Removes the associated file for a given filepath switch.
(...skipping 11 matching lines...) Expand all
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_.path().Append(filepath_switch);
62 } 62 }
63 63
64 const std::vector<std::string> all_filepath_switches_ = {kClientTokenPath}; 64 const std::vector<std::string> all_filepath_switches_ = {
65 kClientAuthTokenPath};
65 66
66 base::ScopedTempDir temp_dir_; 67 base::ScopedTempDir temp_dir_;
67 }; 68 };
68 69
69 TEST_F(BlimpEngineConfigTest, ClientTokenCorrect) { 70 TEST_F(BlimpEngineConfigTest, ClientAuthTokenCorrect) {
70 auto cmd_line = CreateCommandLine(all_filepath_switches_); 71 auto cmd_line = CreateCommandLine(all_filepath_switches_);
71 auto engine_config = BlimpEngineConfig::Create(cmd_line); 72 auto engine_config = BlimpEngineConfig::Create(cmd_line);
72 EXPECT_NE(nullptr, engine_config); 73 EXPECT_NE(nullptr, engine_config);
73 EXPECT_EQ(kTestClientToken, engine_config->client_token()); 74 EXPECT_EQ(kTestClientAuthToken, engine_config->client_auth_token());
74 } 75 }
75 76
76 TEST_F(BlimpEngineConfigTest, ClientTokenEmpty) { 77 TEST_F(BlimpEngineConfigTest, ClientAuthTokenEmpty) {
77 RemoveFileForSwitch(kClientTokenPath); 78 RemoveFileForSwitch(kClientAuthTokenPath);
78 CreateFileForSwitch(kClientTokenPath, " "); 79 CreateFileForSwitch(kClientAuthTokenPath, " ");
79 auto cmd_line = CreateCommandLine(all_filepath_switches_); 80 auto cmd_line = CreateCommandLine(all_filepath_switches_);
80 auto engine_config = BlimpEngineConfig::Create(cmd_line); 81 auto engine_config = BlimpEngineConfig::Create(cmd_line);
81 EXPECT_EQ(nullptr, engine_config); 82 EXPECT_EQ(nullptr, engine_config);
82 } 83 }
83 84
84 } // namespace 85 } // namespace
85 } // namespace engine 86 } // namespace engine
86 } // namespace blimp 87 } // namespace blimp
OLDNEW
« no previous file with comments | « blimp/engine/app/blimp_engine_config.cc ('k') | blimp/engine/browser_tests/blimp_browser_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698