optimization_guide_test_util.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // Copyright 2020 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 COMPONENTS_OPTIMIZATION_GUIDE_CORE_OPTIMIZATION_GUIDE_TEST_UTIL_H_
  5. #define COMPONENTS_OPTIMIZATION_GUIDE_CORE_OPTIMIZATION_GUIDE_TEST_UTIL_H_
  6. #include <memory>
  7. #include "components/optimization_guide/proto/hints.pb.h"
  8. #include "components/optimization_guide/proto/models.pb.h"
  9. #include "url/gurl.h"
  10. namespace optimization_guide {
  11. enum class HintsFetcherRemoteResponseType {
  12. kSuccessful = 0,
  13. kUnsuccessful = 1,
  14. kMalformed = 2,
  15. kHung = 3,
  16. };
  17. // File paths that can be used in testing, handling platform differences, namely
  18. // C:\ in Windows.
  19. extern const char kTestAbsoluteFilePath[];
  20. extern const char kTestRelativeFilePath[];
  21. // Returns a decision tree model with |threshold|, |weight|, and a single
  22. // uninitialized node.
  23. std::unique_ptr<proto::PredictionModel> GetMinimalDecisionTreePredictionModel(
  24. double threshold,
  25. double weight);
  26. // Returns a decision tree model with |threshold|, |weight|, and a single
  27. // leaf node with |leaf_value|.
  28. std::unique_ptr<proto::PredictionModel>
  29. GetSingleLeafDecisionTreePredictionModel(double threshold,
  30. double weight,
  31. double leaf_value);
  32. // Creates the hints config with |optimization_type| to |hints_url| that returns
  33. // the |metadata|. This config string can be passed to the |kHintsProtoOverride|
  34. // commandline switch.
  35. std::string CreateHintsConfig(const GURL& hints_url,
  36. proto::OptimizationType optimization_type,
  37. proto::Any* metadata);
  38. } // namespace optimization_guide
  39. #endif // COMPONENTS_OPTIMIZATION_GUIDE_CORE_OPTIMIZATION_GUIDE_TEST_UTIL_H_