| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 #include "services/ui/ws/test_change_tracker.h" | 5 #include "services/ui/ws/test_change_tracker.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 | 135 |
| 136 case CHANGE_TYPE_ON_TOP_LEVEL_CREATED: | 136 case CHANGE_TYPE_ON_TOP_LEVEL_CREATED: |
| 137 return base::StringPrintf("TopLevelCreated id=%d window_id=%s drawn=%s", | 137 return base::StringPrintf("TopLevelCreated id=%d window_id=%s drawn=%s", |
| 138 change.change_id, | 138 change.change_id, |
| 139 WindowIdToString(change.window_id).c_str(), | 139 WindowIdToString(change.window_id).c_str(), |
| 140 change.bool_value ? "true" : "false"); | 140 change.bool_value ? "true" : "false"); |
| 141 case CHANGE_TYPE_OPACITY: | 141 case CHANGE_TYPE_OPACITY: |
| 142 return base::StringPrintf("OpacityChanged window_id=%s opacity=%.2f", | 142 return base::StringPrintf("OpacityChanged window_id=%s opacity=%.2f", |
| 143 WindowIdToString(change.window_id).c_str(), | 143 WindowIdToString(change.window_id).c_str(), |
| 144 change.float_value); | 144 change.float_value); |
| 145 case CHANGE_TYPE_SURFACE_CHANGED: | |
| 146 return base::StringPrintf("SurfaceCreated window_id=%s surface_id=%s", | |
| 147 WindowIdToString(change.window_id).c_str(), | |
| 148 change.surface_id.ToString().c_str()); | |
| 149 } | 145 } |
| 150 return std::string(); | 146 return std::string(); |
| 151 } | 147 } |
| 152 | 148 |
| 153 std::string SingleChangeToDescriptionImpl(const std::vector<Change>& changes, | 149 std::string SingleChangeToDescriptionImpl(const std::vector<Change>& changes, |
| 154 ChangeDescriptionType change_type) { | 150 ChangeDescriptionType change_type) { |
| 155 std::string result; | 151 std::string result; |
| 156 for (auto& change : changes) { | 152 for (auto& change : changes) { |
| 157 if (!result.empty()) | 153 if (!result.empty()) |
| 158 result += "\n"; | 154 result += "\n"; |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 mojom::WindowDataPtr window_data, | 414 mojom::WindowDataPtr window_data, |
| 419 bool drawn) { | 415 bool drawn) { |
| 420 Change change; | 416 Change change; |
| 421 change.type = CHANGE_TYPE_ON_TOP_LEVEL_CREATED; | 417 change.type = CHANGE_TYPE_ON_TOP_LEVEL_CREATED; |
| 422 change.change_id = change_id; | 418 change.change_id = change_id; |
| 423 change.window_id = window_data->window_id; | 419 change.window_id = window_data->window_id; |
| 424 change.bool_value = drawn; | 420 change.bool_value = drawn; |
| 425 AddChange(change); | 421 AddChange(change); |
| 426 } | 422 } |
| 427 | 423 |
| 428 void TestChangeTracker::OnWindowSurfaceChanged( | |
| 429 Id window_id, | |
| 430 const cc::SurfaceId& surface_id, | |
| 431 const cc::SurfaceSequence& surface_sequence, | |
| 432 const gfx::Size& frame_size, | |
| 433 float device_scale_factor) { | |
| 434 Change change; | |
| 435 change.type = CHANGE_TYPE_SURFACE_CHANGED; | |
| 436 change.window_id = window_id; | |
| 437 change.surface_id = surface_id; | |
| 438 change.surface_sequence = surface_sequence; | |
| 439 change.frame_size = frame_size; | |
| 440 change.device_scale_factor = device_scale_factor; | |
| 441 AddChange(change); | |
| 442 } | |
| 443 | |
| 444 void TestChangeTracker::AddChange(const Change& change) { | 424 void TestChangeTracker::AddChange(const Change& change) { |
| 445 changes_.push_back(change); | 425 changes_.push_back(change); |
| 446 if (delegate_) | 426 if (delegate_) |
| 447 delegate_->OnChangeAdded(); | 427 delegate_->OnChangeAdded(); |
| 448 } | 428 } |
| 449 | 429 |
| 450 TestWindow::TestWindow() {} | 430 TestWindow::TestWindow() {} |
| 451 | 431 |
| 452 TestWindow::TestWindow(const TestWindow& other) = default; | 432 TestWindow::TestWindow(const TestWindow& other) = default; |
| 453 | 433 |
| 454 TestWindow::~TestWindow() {} | 434 TestWindow::~TestWindow() {} |
| 455 | 435 |
| 456 std::string TestWindow::ToString() const { | 436 std::string TestWindow::ToString() const { |
| 457 return base::StringPrintf("window=%s parent=%s", | 437 return base::StringPrintf("window=%s parent=%s", |
| 458 WindowIdToString(window_id).c_str(), | 438 WindowIdToString(window_id).c_str(), |
| 459 WindowIdToString(parent_id).c_str()); | 439 WindowIdToString(parent_id).c_str()); |
| 460 } | 440 } |
| 461 | 441 |
| 462 std::string TestWindow::ToString2() const { | 442 std::string TestWindow::ToString2() const { |
| 463 return base::StringPrintf( | 443 return base::StringPrintf( |
| 464 "window=%s parent=%s visible=%s", WindowIdToString(window_id).c_str(), | 444 "window=%s parent=%s visible=%s", WindowIdToString(window_id).c_str(), |
| 465 WindowIdToString(parent_id).c_str(), visible ? "true" : "false"); | 445 WindowIdToString(parent_id).c_str(), visible ? "true" : "false"); |
| 466 } | 446 } |
| 467 | 447 |
| 468 } // namespace ws | 448 } // namespace ws |
| 469 | 449 |
| 470 } // namespace ui | 450 } // namespace ui |
| OLD | NEW |