| 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 |
| 11 #include <string> | 11 #include <string> |
| 12 | 12 |
| 13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
| 14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 15 #include "base/env_var.h" | 15 #include "base/environment.h" |
| 16 #include "chrome/common/chrome_switches.h" | 16 #include "chrome/common/chrome_switches.h" |
| 17 #include "chrome/common/env_vars.h" | 17 #include "chrome/common/env_vars.h" |
| 18 #include "chrome/common/logging_chrome.h" | 18 #include "chrome/common/logging_chrome.h" |
| 19 #include "chrome/test/automation/browser_proxy.h" | 19 #include "chrome/test/automation/browser_proxy.h" |
| 20 #include "chrome/test/ui/ui_test.h" | 20 #include "chrome/test/ui/ui_test.h" |
| 21 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
| 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::Environment> env(base::Environment::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 env->SetEnv(env_vars::kLogFileName, new_value); | 32 env->SetEnv(env_vars::kLogFileName, new_value); |
| 33 } | 33 } |
| 34 | 34 |
| 35 // Restores the value of the log file nave environment variable | 35 // Restores the value of the log file nave environment variable |
| 36 // previously saved by SaveEnvironmentVariable(). | 36 // previously saved by SaveEnvironmentVariable(). |
| 37 void RestoreEnvironmentVariable() { | 37 void RestoreEnvironmentVariable() { |
| 38 scoped_ptr<base::EnvVarGetter> env(base::EnvVarGetter::Create()); | 38 scoped_ptr<base::Environment> env(base::Environment::Create()); |
| 39 env->SetEnv(env_vars::kLogFileName, environment_filename_); | 39 env->SetEnv(env_vars::kLogFileName, environment_filename_); |
| 40 } | 40 } |
| 41 | 41 |
| 42 private: | 42 private: |
| 43 std::string environment_filename_; // Saves real environment value. | 43 std::string environment_filename_; // Saves real environment value. |
| 44 }; | 44 }; |
| 45 | 45 |
| 46 // Tests the log file name getter without an environment variable. | 46 // Tests the log file name getter without an environment variable. |
| 47 TEST_F(ChromeLoggingTest, LogFileName) { | 47 TEST_F(ChromeLoggingTest, LogFileName) { |
| 48 SaveEnvironmentVariable(""); | 48 SaveEnvironmentVariable(""); |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 if (UITest::in_process_renderer()) { | 180 if (UITest::in_process_renderer()) { |
| 181 // in process mode doesn't do the crashing. | 181 // in process mode doesn't do the crashing. |
| 182 expected_crashes_ = 0; | 182 expected_crashes_ = 0; |
| 183 } else { | 183 } else { |
| 184 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); | 184 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); |
| 185 ASSERT_TRUE(browser.get()); | 185 ASSERT_TRUE(browser.get()); |
| 186 ASSERT_TRUE(browser->WaitForTabCountToBecome(1, action_max_timeout_ms())); | 186 ASSERT_TRUE(browser->WaitForTabCountToBecome(1, action_max_timeout_ms())); |
| 187 expected_crashes_ = EXPECTED_CRASH_CRASHES; | 187 expected_crashes_ = EXPECTED_CRASH_CRASHES; |
| 188 } | 188 } |
| 189 } | 189 } |
| OLD | NEW |