| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "build/build_config.h" | 5 #include "build/build_config.h" |
| 6 | 6 |
| 7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 #endif | 9 #endif |
| 10 | 10 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 class ChromeLoggingTest : public testing::Test { | 23 class ChromeLoggingTest : public testing::Test { |
| 24 public: | 24 public: |
| 25 // Stores the current value of the log file name environment | 25 // Stores the current value of the log file name environment |
| 26 // variable and sets the variable to new_value. | 26 // variable and sets the variable to new_value. |
| 27 void SaveEnvironmentVariable(std::string new_value) { | 27 void SaveEnvironmentVariable(std::string new_value) { |
| 28 scoped_ptr<base::EnvVarGetter> env(base::EnvVarGetter::Create()); | 28 scoped_ptr<base::EnvVarGetter> env(base::EnvVarGetter::Create()); |
| 29 if (!env->GetEnv(env_vars::kLogFileName, &environment_filename_)) | 29 if (!env->GetEnv(env_vars::kLogFileName, &environment_filename_)) |
| 30 environment_filename_ = ""; | 30 environment_filename_ = ""; |
| 31 | 31 |
| 32 // TODO(port) Add base::SetEnv() and get rid of the ifdefs. | 32 env->SetEnv(env_vars::kLogFileName, new_value); |
| 33 #if defined(OS_WIN) | |
| 34 SetEnvironmentVariable(ASCIIToWide(env_vars::kLogFileName).c_str(), | |
| 35 ASCIIToWide(new_value).c_str()); | |
| 36 #else | |
| 37 setenv(env_vars::kLogFileName, new_value.c_str(), 1); | |
| 38 #endif | |
| 39 } | 33 } |
| 40 | 34 |
| 41 // Restores the value of the log file nave environment variable | 35 // Restores the value of the log file nave environment variable |
| 42 // previously saved by SaveEnvironmentVariable(). | 36 // previously saved by SaveEnvironmentVariable(). |
| 43 void RestoreEnvironmentVariable() { | 37 void RestoreEnvironmentVariable() { |
| 44 #if defined(OS_WIN) | 38 scoped_ptr<base::EnvVarGetter> env(base::EnvVarGetter::Create()); |
| 45 SetEnvironmentVariable(ASCIIToWide(env_vars::kLogFileName).c_str(), | 39 env->SetEnv(env_vars::kLogFileName, environment_filename_); |
| 46 ASCIIToWide(environment_filename_).c_str()); | |
| 47 #else | |
| 48 setenv(env_vars::kLogFileName, environment_filename_.c_str(), 1); | |
| 49 #endif | |
| 50 } | 40 } |
| 51 | 41 |
| 52 private: | 42 private: |
| 53 std::string environment_filename_; // Saves real environment value. | 43 std::string environment_filename_; // Saves real environment value. |
| 54 }; | 44 }; |
| 55 | 45 |
| 56 // Tests the log file name getter without an environment variable. | 46 // Tests the log file name getter without an environment variable. |
| 57 TEST_F(ChromeLoggingTest, LogFileName) { | 47 TEST_F(ChromeLoggingTest, LogFileName) { |
| 58 SaveEnvironmentVariable(""); | 48 SaveEnvironmentVariable(""); |
| 59 | 49 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 if (UITest::in_process_renderer()) { | 177 if (UITest::in_process_renderer()) { |
| 188 // in process mode doesn't do the crashing. | 178 // in process mode doesn't do the crashing. |
| 189 expected_crashes_ = 0; | 179 expected_crashes_ = 0; |
| 190 } else { | 180 } else { |
| 191 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); | 181 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); |
| 192 ASSERT_TRUE(browser.get()); | 182 ASSERT_TRUE(browser.get()); |
| 193 ASSERT_TRUE(browser->WaitForTabCountToBecome(1, action_max_timeout_ms())); | 183 ASSERT_TRUE(browser->WaitForTabCountToBecome(1, action_max_timeout_ms())); |
| 194 expected_crashes_ = EXPECTED_CRASH_CRASHES; | 184 expected_crashes_ = EXPECTED_CRASH_CRASHES; |
| 195 } | 185 } |
| 196 } | 186 } |
| OLD | NEW |