OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef COMPONENTS_TEST_RUNNER_LAYOUT_DUMP_FLAGS_H_ | 5 #ifndef COMPONENTS_TEST_RUNNER_LAYOUT_DUMP_FLAGS_H_ |
6 #define COMPONENTS_TEST_RUNNER_LAYOUT_DUMP_FLAGS_H_ | 6 #define COMPONENTS_TEST_RUNNER_LAYOUT_DUMP_FLAGS_H_ |
7 | 7 |
8 #include <string> | |
9 | |
10 #include "base/logging.h" | |
11 #include "base/macros.h" | |
12 #include "base/values.h" | |
13 #include "components/test_runner/test_runner_export.h" | |
14 #include "components/test_runner/tracked_dictionary.h" | |
15 | |
8 namespace test_runner { | 16 namespace test_runner { |
9 | 17 |
10 struct LayoutDumpFlags { | 18 // TODO(lukasza): Rename to LayoutTestRuntimeFlags. |
11 LayoutDumpFlags(bool dump_as_text, | 19 class TEST_RUNNER_EXPORT LayoutDumpFlags { |
12 bool dump_child_frames_as_text, | 20 public: |
13 bool dump_as_markup, | 21 // Creates default flags (see also the Reset method). |
14 bool dump_child_frames_as_markup, | 22 LayoutDumpFlags(); |
15 bool dump_child_frame_scroll_positions, | |
16 bool is_printing) | |
17 : dump_as_text(dump_as_text), | |
18 dump_child_frames_as_text(dump_child_frames_as_text), | |
19 dump_as_markup(dump_as_text), | |
20 dump_child_frames_as_markup(dump_child_frames_as_markup), | |
21 dump_child_frame_scroll_positions(dump_child_frame_scroll_positions), | |
22 is_printing(is_printing) {} | |
23 | 23 |
24 // Default constructor needed for IPC. | 24 // Resets all the values to their defaults. |
25 // | 25 void Reset(); |
26 // Default constructor is |= default| to make sure LayoutDumpFlags is a POD | 26 |
27 // (required until we can remove content/shell/browser dependency on it). | 27 TrackedDictionary& tracked_dictionary() { return dict_; } |
28 LayoutDumpFlags() = default; | 28 const TrackedDictionary& tracked_dictionary() const { return dict_; } |
29 | |
30 #define DEFINE_BOOL_LAYOUT_DUMP_FLAG(name) \ | |
31 bool name() const { \ | |
32 bool result; \ | |
33 bool found = dict_.current_values().GetBoolean(#name, &result); \ | |
34 DCHECK(found); \ | |
35 return result; \ | |
36 } \ | |
37 void set_##name(bool new_value) { dict_.SetBoolean(#name, new_value); } | |
38 | |
39 // If true, the test_shell will generate pixel results in DumpAsText mode. | |
40 DEFINE_BOOL_LAYOUT_DUMP_FLAG(generate_pixel_results) | |
29 | 41 |
30 // If true, the test_shell will produce a plain text dump rather than a | 42 // If true, the test_shell will produce a plain text dump rather than a |
31 // text representation of the renderer. | 43 // text representation of the renderer. |
32 bool dump_as_text; | 44 DEFINE_BOOL_LAYOUT_DUMP_FLAG(dump_as_text) |
33 | 45 |
34 // If true and if dump_as_text_ is true, the test_shell will recursively | 46 // If true and if dump_as_text_ is true, the test_shell will recursively |
35 // dump all frames as plain text. | 47 // dump all frames as plain text. |
36 bool dump_child_frames_as_text; | 48 DEFINE_BOOL_LAYOUT_DUMP_FLAG(dump_child_frames_as_text) |
37 | 49 |
38 // If true, the test_shell will produce a dump of the DOM rather than a text | 50 // If true, the test_shell will produce a dump of the DOM rather than a text |
39 // representation of the layout objects. | 51 // representation of the renderer. |
40 bool dump_as_markup; | 52 DEFINE_BOOL_LAYOUT_DUMP_FLAG(dump_as_markup) |
41 | 53 |
42 // If true and if dump_as_markup_ is true, the test_shell will recursively | 54 // If true and if dump_as_markup_ is true, the test_shell will recursively |
43 // produce a dump of the DOM rather than a text representation of the | 55 // produce a dump of the DOM rather than a text representation of the |
44 // layout objects. | 56 // renderer. |
45 bool dump_child_frames_as_markup; | 57 DEFINE_BOOL_LAYOUT_DUMP_FLAG(dump_child_frames_as_markup) |
46 | 58 |
47 // If true, the test_shell will print out the child frame scroll offsets as | 59 // If true, the test_shell will print out the child frame scroll offsets as |
48 // well. | 60 // well. |
49 bool dump_child_frame_scroll_positions; | 61 DEFINE_BOOL_LAYOUT_DUMP_FLAG(dump_child_frame_scroll_positions) |
62 | |
63 // If true, layout is to target printed pages. | |
64 DEFINE_BOOL_LAYOUT_DUMP_FLAG(is_printing) | |
65 | |
66 // If true, don't dump output until notifyDone is called. | |
67 DEFINE_BOOL_LAYOUT_DUMP_FLAG(wait_until_done) | |
50 | 68 |
dcheng
2016/03/08 23:09:37
#undef DEFINE_BOOL_LAYOUT_DUMP_FLAG.
Łukasz Anforowicz
2016/03/10 22:24:21
Done. Good point.
| |
51 // Reports whether recursing over child frames is necessary. | 69 // Reports whether recursing over child frames is necessary. |
52 bool dump_child_frames() const { | 70 bool dump_child_frames() const { |
53 if (dump_as_text) | 71 if (dump_as_text()) |
54 return dump_child_frames_as_text; | 72 return dump_child_frames_as_text(); |
55 else if (dump_as_markup) | 73 else if (dump_as_markup()) |
56 return dump_child_frames_as_markup; | 74 return dump_child_frames_as_markup(); |
57 else | 75 else |
58 return dump_child_frame_scroll_positions; | 76 return dump_child_frame_scroll_positions(); |
59 } | 77 } |
60 | 78 |
61 // If true, layout is to target printed pages. | 79 private: |
62 bool is_printing; | 80 TrackedDictionary dict_; |
81 | |
82 DISALLOW_COPY_AND_ASSIGN(LayoutDumpFlags); | |
63 }; | 83 }; |
64 | 84 |
65 } // namespace test_runner | 85 } // namespace test_runner |
66 | 86 |
67 #endif // COMPONENTS_TEST_RUNNER_LAYOUT_DUMP_FLAGS_H_ | 87 #endif // COMPONENTS_TEST_RUNNER_LAYOUT_DUMP_FLAGS_H_ |
OLD | NEW |