google_api_keys_unittest.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. #ifndef GOOGLE_APIS_GOOGLE_API_KEYS_UNITTEST_H_
  5. #define GOOGLE_APIS_GOOGLE_API_KEYS_UNITTEST_H_
  6. #include <memory>
  7. #include <string>
  8. #include "base/environment.h"
  9. #include "google_apis/google_api_keys.h"
  10. #include "testing/gtest/include/gtest/gtest.h"
  11. struct EnvironmentCache {
  12. EnvironmentCache() : variable_name(nullptr), was_set(false) {}
  13. const char* variable_name;
  14. bool was_set;
  15. std::string value;
  16. };
  17. class GoogleAPIKeysTest : public testing::Test {
  18. public:
  19. GoogleAPIKeysTest();
  20. ~GoogleAPIKeysTest() override;
  21. void SetUp() override;
  22. void TearDown() override;
  23. private:
  24. std::unique_ptr<base::Environment> env_;
  25. // Why 3? It is for GOOGLE_API_KEY, GOOGLE_DEFAULT_CLIENT_ID and
  26. // GOOGLE_DEFAULT_CLIENT_SECRET.
  27. //
  28. // Why 2 times CLIENT_NUM_ITEMS? This is the number of different
  29. // clients in the OAuth2Client enumeration, and for each of these we
  30. // have both an ID and a secret.
  31. EnvironmentCache env_cache_[3 + 2 * google_apis::CLIENT_NUM_ITEMS];
  32. };
  33. #endif // GOOGLE_APIS_GOOGLE_API_KEYS_UNITTEST_H_