| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // Unit tests for implementation of google_api_keys namespace. | 5 // Unit tests for implementation of google_api_keys namespace. |
| 6 // | 6 // |
| 7 // Because the file deals with a lot of preprocessor defines and | 7 // Because the file deals with a lot of preprocessor defines and |
| 8 // optionally includes an internal header, the way we test is by | 8 // optionally includes an internal header, the way we test is by |
| 9 // including the .cc file multiple times with different defines set. | 9 // including the .cc file multiple times with different defines set. |
| 10 // This is a little unorthodox, but it lets us test the behavior as | 10 // This is a little unorthodox, but it lets us test the behavior as |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 env_cache_[3].variable_name = "GOOGLE_CLIENT_ID_CLOUD_PRINT"; | 59 env_cache_[3].variable_name = "GOOGLE_CLIENT_ID_CLOUD_PRINT"; |
| 60 env_cache_[4].variable_name = "GOOGLE_CLIENT_SECRET_CLOUD_PRINT"; | 60 env_cache_[4].variable_name = "GOOGLE_CLIENT_SECRET_CLOUD_PRINT"; |
| 61 env_cache_[5].variable_name = "GOOGLE_CLIENT_ID_REMOTING"; | 61 env_cache_[5].variable_name = "GOOGLE_CLIENT_ID_REMOTING"; |
| 62 env_cache_[6].variable_name = "GOOGLE_CLIENT_SECRET_REMOTING"; | 62 env_cache_[6].variable_name = "GOOGLE_CLIENT_SECRET_REMOTING"; |
| 63 env_cache_[7].variable_name = "GOOGLE_CLIENT_ID_REMOTING_HOST"; | 63 env_cache_[7].variable_name = "GOOGLE_CLIENT_ID_REMOTING_HOST"; |
| 64 env_cache_[8].variable_name = "GOOGLE_CLIENT_SECRET_REMOTING_HOST"; | 64 env_cache_[8].variable_name = "GOOGLE_CLIENT_SECRET_REMOTING_HOST"; |
| 65 env_cache_[9].variable_name = "GOOGLE_DEFAULT_CLIENT_ID"; | 65 env_cache_[9].variable_name = "GOOGLE_DEFAULT_CLIENT_ID"; |
| 66 env_cache_[10].variable_name = "GOOGLE_DEFAULT_CLIENT_SECRET"; | 66 env_cache_[10].variable_name = "GOOGLE_DEFAULT_CLIENT_SECRET"; |
| 67 } | 67 } |
| 68 | 68 |
| 69 virtual void SetUp() { | 69 void SetUp() override { |
| 70 // Unset all environment variables that can affect these tests, | 70 // Unset all environment variables that can affect these tests, |
| 71 // for the duration of the tests. | 71 // for the duration of the tests. |
| 72 for (size_t i = 0; i < arraysize(env_cache_); ++i) { | 72 for (size_t i = 0; i < arraysize(env_cache_); ++i) { |
| 73 EnvironmentCache& cache = env_cache_[i]; | 73 EnvironmentCache& cache = env_cache_[i]; |
| 74 cache.was_set = env_->HasVar(cache.variable_name); | 74 cache.was_set = env_->HasVar(cache.variable_name); |
| 75 cache.value.clear(); | 75 cache.value.clear(); |
| 76 if (cache.was_set) { | 76 if (cache.was_set) { |
| 77 env_->GetVar(cache.variable_name, &cache.value); | 77 env_->GetVar(cache.variable_name, &cache.value); |
| 78 env_->UnSetVar(cache.variable_name); | 78 env_->UnSetVar(cache.variable_name); |
| 79 } | 79 } |
| 80 } | 80 } |
| 81 } | 81 } |
| 82 | 82 |
| 83 virtual void TearDown() { | 83 void TearDown() override { |
| 84 // Restore environment. | 84 // Restore environment. |
| 85 for (size_t i = 0; i < arraysize(env_cache_); ++i) { | 85 for (size_t i = 0; i < arraysize(env_cache_); ++i) { |
| 86 EnvironmentCache& cache = env_cache_[i]; | 86 EnvironmentCache& cache = env_cache_[i]; |
| 87 if (cache.was_set) { | 87 if (cache.was_set) { |
| 88 env_->SetVar(cache.variable_name, cache.value); | 88 env_->SetVar(cache.variable_name, cache.value); |
| 89 } | 89 } |
| 90 } | 90 } |
| 91 } | 91 } |
| 92 | 92 |
| 93 private: | 93 private: |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 EXPECT_EQ("env-SECRET_MAIN", secret_main); | 489 EXPECT_EQ("env-SECRET_MAIN", secret_main); |
| 490 EXPECT_EQ("env-ID_CLOUD_PRINT", id_cloud_print); | 490 EXPECT_EQ("env-ID_CLOUD_PRINT", id_cloud_print); |
| 491 EXPECT_EQ("env-SECRET_CLOUD_PRINT", secret_cloud_print); | 491 EXPECT_EQ("env-SECRET_CLOUD_PRINT", secret_cloud_print); |
| 492 EXPECT_EQ("env-ID_REMOTING", id_remoting); | 492 EXPECT_EQ("env-ID_REMOTING", id_remoting); |
| 493 EXPECT_EQ("env-SECRET_REMOTING", secret_remoting); | 493 EXPECT_EQ("env-SECRET_REMOTING", secret_remoting); |
| 494 EXPECT_EQ("env-ID_REMOTING_HOST", id_remoting_host); | 494 EXPECT_EQ("env-ID_REMOTING_HOST", id_remoting_host); |
| 495 EXPECT_EQ("env-SECRET_REMOTING_HOST", secret_remoting_host); | 495 EXPECT_EQ("env-SECRET_REMOTING_HOST", secret_remoting_host); |
| 496 } | 496 } |
| 497 | 497 |
| 498 #endif // defined(OS_LINUX) || defined(OS_MACOSX) | 498 #endif // defined(OS_LINUX) || defined(OS_MACOSX) |
| OLD | NEW |