bzanotti | bd01460 | 2016-08-10 18:42:58 | [diff] [blame] | 1 | // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef GOOGLE_APIS_GOOGLE_API_KEYS_UNITTEST_H_ |
| 6 | #define GOOGLE_APIS_GOOGLE_API_KEYS_UNITTEST_H_ |
| 7 | |
| 8 | #include <memory> |
| 9 | #include <string> |
| 10 | |
| 11 | #include "base/environment.h" |
| 12 | #include "google_apis/google_api_keys.h" |
| 13 | #include "testing/gtest/include/gtest/gtest.h" |
| 14 | |
| 15 | struct EnvironmentCache { |
| 16 | EnvironmentCache() : variable_name(nullptr), was_set(false) {} |
| 17 | |
| 18 | const char* variable_name; |
| 19 | bool was_set; |
| 20 | std::string value; |
| 21 | }; |
| 22 | |
| 23 | class GoogleAPIKeysTest : public testing::Test { |
| 24 | public: |
| 25 | GoogleAPIKeysTest(); |
| 26 | ~GoogleAPIKeysTest() override; |
| 27 | void SetUp() override; |
| 28 | void TearDown() override; |
| 29 | |
| 30 | private: |
| 31 | std::unique_ptr<base::Environment> env_; |
| 32 | |
| 33 | // Why 3? It is for GOOGLE_API_KEY, GOOGLE_DEFAULT_CLIENT_ID and |
| 34 | // GOOGLE_DEFAULT_CLIENT_SECRET. |
| 35 | // |
| 36 | // Why 2 times CLIENT_NUM_ITEMS? This is the number of different |
| 37 | // clients in the OAuth2Client enumeration, and for each of these we |
| 38 | // have both an ID and a secret. |
| 39 | EnvironmentCache env_cache_[3 + 2 * google_apis::CLIENT_NUM_ITEMS]; |
| 40 | }; |
| 41 | |
| 42 | #endif // GOOGLE_APIS_GOOGLE_API_KEYS_UNITTEST_H_ |