view_tree_validator.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // Copyright 2017 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 UI_BASE_TEST_VIEW_TREE_VALIDATOR_H_
  5. #define UI_BASE_TEST_VIEW_TREE_VALIDATOR_H_
  6. #include "third_party/abseil-cpp/absl/types/optional.h"
  7. @class NSView;
  8. namespace ui {
  9. struct ViewTreeProblemDetails {
  10. enum ProblemType {
  11. // |view_a| (the child view) is not entirely contained within the bounds of
  12. // |view_b| (the parent view).
  13. VIEW_OUTSIDE_PARENT,
  14. // |view_a| and |view_b|, neither of which is an ancestor of the other,
  15. // overlap each other, and at least one of |view_a| or |view_b| has
  16. // localizable text (is an NSControl or NSText).
  17. VIEWS_OVERLAP,
  18. };
  19. ProblemType type;
  20. NSView* view_a;
  21. NSView* view_b;
  22. std::string ToString();
  23. };
  24. // Validates the view tree rooted at |root|. If at least one problem is found,
  25. // returns a |ViewTreeProblemDetails| as described above; if not, returns an
  26. // empty option.
  27. absl::optional<ViewTreeProblemDetails> ValidateViewTree(NSView* root);
  28. } // namespace ui
  29. #endif // UI_BASE_TEST_VIEW_TREE_VALIDATOR_H_