Chromium Code Reviews| Index: components/test_runner/layout_dump_flags.h |
| diff --git a/components/test_runner/layout_dump_flags.h b/components/test_runner/layout_dump_flags.h |
| index 06855eeb38897eb3983a57d3941194998e0c51a7..f5d07ea5705ad920c30f54e0d4de7bc801c03947 100644 |
| --- a/components/test_runner/layout_dump_flags.h |
| +++ b/components/test_runner/layout_dump_flags.h |
| @@ -5,61 +5,81 @@ |
| #ifndef COMPONENTS_TEST_RUNNER_LAYOUT_DUMP_FLAGS_H_ |
| #define COMPONENTS_TEST_RUNNER_LAYOUT_DUMP_FLAGS_H_ |
| +#include <string> |
| + |
| +#include "base/logging.h" |
| +#include "base/macros.h" |
| +#include "base/values.h" |
| +#include "components/test_runner/test_runner_export.h" |
| +#include "components/test_runner/tracked_dictionary.h" |
| + |
| namespace test_runner { |
| -struct LayoutDumpFlags { |
| - LayoutDumpFlags(bool dump_as_text, |
| - bool dump_child_frames_as_text, |
| - bool dump_as_markup, |
| - bool dump_child_frames_as_markup, |
| - bool dump_child_frame_scroll_positions, |
| - bool is_printing) |
| - : dump_as_text(dump_as_text), |
| - dump_child_frames_as_text(dump_child_frames_as_text), |
| - dump_as_markup(dump_as_text), |
| - dump_child_frames_as_markup(dump_child_frames_as_markup), |
| - dump_child_frame_scroll_positions(dump_child_frame_scroll_positions), |
| - is_printing(is_printing) {} |
|
Łukasz Anforowicz
2016/03/03 21:46:34
I’ve removed the LayoutDumpFlags constructor takin
|
| - |
| - // Default constructor needed for IPC. |
| - // |
| - // Default constructor is |= default| to make sure LayoutDumpFlags is a POD |
| - // (required until we can remove content/shell/browser dependency on it). |
| - LayoutDumpFlags() = default; |
| +// TODO(lukasza): Rename to LayoutTestRuntimeFlags. |
| +class TEST_RUNNER_EXPORT LayoutDumpFlags { |
| + public: |
| + // Creates default flags (see also the Reset method). |
| + LayoutDumpFlags(); |
| + |
| + // Resets all the values to their defaults. |
| + void Reset(); |
| + |
| + TrackedDictionary& tracked_dictionary() { return dict_; } |
| + const TrackedDictionary& tracked_dictionary() const { return dict_; } |
| + |
| +#define DEFINE_BOOL_LAYOUT_DUMP_FLAG(name) \ |
| + bool name() const { \ |
| + bool result; \ |
| + bool found = dict_.current_values().GetBoolean(#name, &result); \ |
| + DCHECK(found); \ |
| + return result; \ |
| + } \ |
| + void set_##name(bool new_value) { dict_.SetBoolean(#name, new_value); } |
|
Łukasz Anforowicz
2016/03/03 21:46:34
I am not very happy about using macros here, but I
|
| + |
| + // If true, the test_shell will generate pixel results in DumpAsText mode. |
| + DEFINE_BOOL_LAYOUT_DUMP_FLAG(generate_pixel_results) |
| // If true, the test_shell will produce a plain text dump rather than a |
| // text representation of the renderer. |
| - bool dump_as_text; |
| + DEFINE_BOOL_LAYOUT_DUMP_FLAG(dump_as_text) |
| // If true and if dump_as_text_ is true, the test_shell will recursively |
| // dump all frames as plain text. |
| - bool dump_child_frames_as_text; |
| + DEFINE_BOOL_LAYOUT_DUMP_FLAG(dump_child_frames_as_text) |
| // If true, the test_shell will produce a dump of the DOM rather than a text |
| - // representation of the layout objects. |
| - bool dump_as_markup; |
| + // representation of the renderer. |
| + DEFINE_BOOL_LAYOUT_DUMP_FLAG(dump_as_markup) |
| // If true and if dump_as_markup_ is true, the test_shell will recursively |
| // produce a dump of the DOM rather than a text representation of the |
| - // layout objects. |
| - bool dump_child_frames_as_markup; |
| + // renderer. |
| + DEFINE_BOOL_LAYOUT_DUMP_FLAG(dump_child_frames_as_markup) |
| // If true, the test_shell will print out the child frame scroll offsets as |
| // well. |
| - bool dump_child_frame_scroll_positions; |
| + DEFINE_BOOL_LAYOUT_DUMP_FLAG(dump_child_frame_scroll_positions) |
| + |
| + // If true, layout is to target printed pages. |
| + DEFINE_BOOL_LAYOUT_DUMP_FLAG(is_printing) |
| + |
| + // If true, don't dump output until notifyDone is called. |
| + DEFINE_BOOL_LAYOUT_DUMP_FLAG(wait_until_done) |
| // Reports whether recursing over child frames is necessary. |
| bool dump_child_frames() const { |
| - if (dump_as_text) |
| - return dump_child_frames_as_text; |
| - else if (dump_as_markup) |
| - return dump_child_frames_as_markup; |
| + if (dump_as_text()) |
| + return dump_child_frames_as_text(); |
| + else if (dump_as_markup()) |
| + return dump_child_frames_as_markup(); |
| else |
| - return dump_child_frame_scroll_positions; |
| + return dump_child_frame_scroll_positions(); |
| } |
| - // If true, layout is to target printed pages. |
| - bool is_printing; |
| + private: |
| + TrackedDictionary dict_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(LayoutDumpFlags); |
| }; |
| } // namespace test_runner |