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

Side by Side Diff: chrome/browser/logging_chrome_unittest.cc

Issue 1349783006: Cleanup: Pass std::string as const reference if possible (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert third_party changes Created 5 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/environment.h" 5 #include "base/environment.h"
6 #include "base/files/file_path.h" 6 #include "base/files/file_path.h"
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "chrome/common/env_vars.h" 8 #include "chrome/common/env_vars.h"
9 #include "chrome/common/logging_chrome.h" 9 #include "chrome/common/logging_chrome.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 11
12 class ChromeLoggingTest : public testing::Test { 12 class ChromeLoggingTest : public testing::Test {
13 public: 13 public:
14 // Stores the current value of the log file name environment 14 // Stores the current value of the log file name environment
15 // variable and sets the variable to new_value. 15 // variable and sets the variable to new_value.
16 void SaveEnvironmentVariable(std::string new_value) { 16 void SaveEnvironmentVariable(const std::string& new_value) {
17 scoped_ptr<base::Environment> env(base::Environment::Create()); 17 scoped_ptr<base::Environment> env(base::Environment::Create());
18 if (!env->GetVar(env_vars::kLogFileName, &environment_filename_)) 18 if (!env->GetVar(env_vars::kLogFileName, &environment_filename_))
19 environment_filename_ = ""; 19 environment_filename_ = "";
20 20
21 env->SetVar(env_vars::kLogFileName, new_value); 21 env->SetVar(env_vars::kLogFileName, new_value);
22 } 22 }
23 23
24 // Restores the value of the log file nave environment variable 24 // Restores the value of the log file nave environment variable
25 // previously saved by SaveEnvironmentVariable(). 25 // previously saved by SaveEnvironmentVariable().
26 void RestoreEnvironmentVariable() { 26 void RestoreEnvironmentVariable() {
(...skipping 19 matching lines...) Expand all
46 // Tests the log file name getter with an environment variable. 46 // Tests the log file name getter with an environment variable.
47 TEST_F(ChromeLoggingTest, EnvironmentLogFileName) { 47 TEST_F(ChromeLoggingTest, EnvironmentLogFileName) {
48 SaveEnvironmentVariable("test value"); 48 SaveEnvironmentVariable("test value");
49 49
50 base::FilePath filename = logging::GetLogFileName(); 50 base::FilePath filename = logging::GetLogFileName();
51 ASSERT_EQ(base::FilePath(FILE_PATH_LITERAL("test value")).value(), 51 ASSERT_EQ(base::FilePath(FILE_PATH_LITERAL("test value")).value(),
52 filename.value()); 52 filename.value());
53 53
54 RestoreEnvironmentVariable(); 54 RestoreEnvironmentVariable();
55 } 55 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698