Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / ui / display / chromeos / test / action_logger_util.cc
blobbbdad78bf5eba357a2ad825ec20d2f54746e5508
1 // Copyright 2014 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.
5 #include "ui/display/chromeos/test/action_logger_util.h"
7 #include "base/format_macros.h"
8 #include "base/logging.h"
9 #include "base/strings/stringprintf.h"
10 #include "ui/display/types/display_mode.h"
11 #include "ui/display/types/display_snapshot.h"
12 #include "ui/display/types/gamma_ramp_rgb_entry.h"
13 #include "ui/display/types/native_display_delegate.h"
14 #include "ui/gfx/geometry/point.h"
15 #include "ui/gfx/geometry/size.h"
17 namespace ui {
18 namespace test {
20 std::string DisplaySnapshotToString(const DisplaySnapshot& output) {
21 return base::StringPrintf("id=%" PRId64, output.display_id());
24 std::string GetBackgroundAction(uint32_t color_argb) {
25 return base::StringPrintf("background(0x%x)", color_argb);
28 std::string GetAddOutputModeAction(const DisplaySnapshot& output,
29 const DisplayMode* mode) {
30 return base::StringPrintf("add_mode(output=%" PRId64 ",mode=%s)",
31 output.display_id(), mode->ToString().c_str());
34 std::string GetCrtcAction(const DisplaySnapshot& output,
35 const DisplayMode* mode,
36 const gfx::Point& origin) {
37 return base::StringPrintf("crtc(display=[%s],x=%d,y=%d,mode=[%s])",
38 DisplaySnapshotToString(output).c_str(), origin.x(),
39 origin.y(),
40 mode ? mode->ToString().c_str() : "NULL");
43 std::string GetFramebufferAction(const gfx::Size& size,
44 const DisplaySnapshot* out1,
45 const DisplaySnapshot* out2) {
46 return base::StringPrintf(
47 "framebuffer(width=%d,height=%d,display1=%s,display2=%s)", size.width(),
48 size.height(), out1 ? DisplaySnapshotToString(*out1).c_str() : "NULL",
49 out2 ? DisplaySnapshotToString(*out2).c_str() : "NULL");
52 std::string GetSetHDCPStateAction(const DisplaySnapshot& output,
53 HDCPState state) {
54 return base::StringPrintf("set_hdcp(id=%" PRId64 ",state=%d)",
55 output.display_id(), state);
58 std::string SetGammaRampAction(const ui::DisplaySnapshot& output,
59 const std::vector<GammaRampRGBEntry>& lut) {
60 std::string table;
61 for (size_t i = 0; i < lut.size(); ++i) {
62 table += base::StringPrintf(",rgb[%" PRIuS "]=%04x%04x%04x", i, lut[i].r,
63 lut[i].g, lut[i].b);
66 return base::StringPrintf("set_gamma_ramp(id=%" PRId64 "%s)",
67 output.display_id(), table.c_str());
70 std::string JoinActions(const char* action, ...) {
71 std::string actions;
73 va_list arg_list;
74 va_start(arg_list, action);
75 while (action) {
76 if (!actions.empty())
77 actions += ",";
78 actions += action;
79 action = va_arg(arg_list, const char*);
81 va_end(arg_list);
82 return actions;
85 } // namespace test
86 } // namespace ui