| 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()); |
| 145 } | 149 } |
| 146 return std::string(); | 150 return std::string(); |
| 147 } | 151 } |
| 148 | 152 |
| 149 std::string SingleChangeToDescriptionImpl(const std::vector<Change>& changes, | 153 std::string SingleChangeToDescriptionImpl(const std::vector<Change>& changes, |
| 150 ChangeDescriptionType change_type) { | 154 ChangeDescriptionType change_type) { |
| 151 std::string result; | 155 std::string result; |
| 152 for (auto& change : changes) { | 156 for (auto& change : changes) { |
| 153 if (!result.empty()) | 157 if (!result.empty()) |
| 154 result += "\n"; | 158 result += "\n"; |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 mojom::WindowDataPtr window_data, | 418 mojom::WindowDataPtr window_data, |
| 415 bool drawn) { | 419 bool drawn) { |
| 416 Change change; | 420 Change change; |
| 417 change.type = CHANGE_TYPE_ON_TOP_LEVEL_CREATED; | 421 change.type = CHANGE_TYPE_ON_TOP_LEVEL_CREATED; |
| 418 change.change_id = change_id; | 422 change.change_id = change_id; |
| 419 change.window_id = window_data->window_id; | 423 change.window_id = window_data->window_id; |
| 420 change.bool_value = drawn; | 424 change.bool_value = drawn; |
| 421 AddChange(change); | 425 AddChange(change); |
| 422 } | 426 } |
| 423 | 427 |
| 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 |
| 424 void TestChangeTracker::AddChange(const Change& change) { | 444 void TestChangeTracker::AddChange(const Change& change) { |
| 425 changes_.push_back(change); | 445 changes_.push_back(change); |
| 426 if (delegate_) | 446 if (delegate_) |
| 427 delegate_->OnChangeAdded(); | 447 delegate_->OnChangeAdded(); |
| 428 } | 448 } |
| 429 | 449 |
| 430 TestWindow::TestWindow() {} | 450 TestWindow::TestWindow() {} |
| 431 | 451 |
| 432 TestWindow::TestWindow(const TestWindow& other) = default; | 452 TestWindow::TestWindow(const TestWindow& other) = default; |
| 433 | 453 |
| 434 TestWindow::~TestWindow() {} | 454 TestWindow::~TestWindow() {} |
| 435 | 455 |
| 436 std::string TestWindow::ToString() const { | 456 std::string TestWindow::ToString() const { |
| 437 return base::StringPrintf("window=%s parent=%s", | 457 return base::StringPrintf("window=%s parent=%s", |
| 438 WindowIdToString(window_id).c_str(), | 458 WindowIdToString(window_id).c_str(), |
| 439 WindowIdToString(parent_id).c_str()); | 459 WindowIdToString(parent_id).c_str()); |
| 440 } | 460 } |
| 441 | 461 |
| 442 std::string TestWindow::ToString2() const { | 462 std::string TestWindow::ToString2() const { |
| 443 return base::StringPrintf( | 463 return base::StringPrintf( |
| 444 "window=%s parent=%s visible=%s", WindowIdToString(window_id).c_str(), | 464 "window=%s parent=%s visible=%s", WindowIdToString(window_id).c_str(), |
| 445 WindowIdToString(parent_id).c_str(), visible ? "true" : "false"); | 465 WindowIdToString(parent_id).c_str(), visible ? "true" : "false"); |
| 446 } | 466 } |
| 447 | 467 |
| 448 } // namespace ws | 468 } // namespace ws |
| 449 | 469 |
| 450 } // namespace ui | 470 } // namespace ui |
| OLD | NEW |