onc_test_utils.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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
  3. // found in the LICENSE file.
  4. #ifndef CHROMEOS_COMPONENTS_ONC_ONC_TEST_UTILS_H_
  5. #define CHROMEOS_COMPONENTS_ONC_ONC_TEST_UTILS_H_
  6. #include <memory>
  7. #include <string>
  8. #include "base/values.h"
  9. #include "testing/gtest/include/gtest/gtest.h"
  10. namespace chromeos {
  11. namespace onc {
  12. namespace test_utils {
  13. // Read the file at |filename| as a string. CHECKs if any error occurs.
  14. std::string ReadTestData(const std::string& filename);
  15. // Read a JSON from |filename| and return it as a base::Value.
  16. // CHECKs if any error occurs.
  17. base::Value ReadTestJson(const std::string& filename);
  18. // Read a JSON dictionary from |filename| and return it as a base::Value.
  19. // CHECKs if any error occurs.
  20. base::Value ReadTestDictionaryValue(const std::string& filename);
  21. // Checks that the pointer |actual| is not NULL but points to a value that
  22. // equals |expected|. The intended use case is:
  23. // EXPECT_TRUE(test_utils::Equals(expected, actual));
  24. ::testing::AssertionResult Equals(const base::Value* expected,
  25. const base::Value* actual);
  26. } // namespace test_utils
  27. } // namespace onc
  28. } // namespace chromeos
  29. // TODO(https://crbug.com/1164001): remove when it moved to ash.
  30. namespace ash::onc::test_utils {
  31. using ::chromeos::onc::test_utils::Equals;
  32. using ::chromeos::onc::test_utils::ReadTestData;
  33. using ::chromeos::onc::test_utils::ReadTestDictionaryValue;
  34. using ::chromeos::onc::test_utils::ReadTestJson;
  35. } // namespace ash::onc::test_utils
  36. #endif // CHROMEOS_COMPONENTS_ONC_ONC_TEST_UTILS_H_