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"
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(),
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
,
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
) {
61 for (size_t i
= 0; i
< lut
.size(); ++i
) {
62 table
+= base::StringPrintf(",rgb[%" PRIuS
"]=%04x%04x%04x", i
, lut
[i
].r
,
66 return base::StringPrintf("set_gamma_ramp(id=%" PRId64
"%s)",
67 output
.display_id(), table
.c_str());
70 std::string
JoinActions(const char* action
, ...) {
74 va_start(arg_list
, action
);
79 action
= va_arg(arg_list
, const char*);