OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "base/test/trace_event_analyzer.h" | 10 #include "base/test/trace_event_analyzer.h" |
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
525 return; | 525 return; |
526 | 526 |
527 const base::FilePath url( | 527 const base::FilePath url( |
528 FILE_PATH_LITERAL("feature_compositing_static.html")); | 528 FILE_PATH_LITERAL("feature_compositing_static.html")); |
529 base::FilePath test_path = gpu_test_dir_.Append(url); | 529 base::FilePath test_path = gpu_test_dir_.Append(url); |
530 ASSERT_TRUE(base::PathExists(test_path)) | 530 ASSERT_TRUE(base::PathExists(test_path)) |
531 << "Missing test file: " << test_path.value(); | 531 << "Missing test file: " << test_path.value(); |
532 | 532 |
533 ui_test_utils::NavigateToURL(browser(), net::FilePathToFileURL(test_path)); | 533 ui_test_utils::NavigateToURL(browser(), net::FilePathToFileURL(test_path)); |
534 | 534 |
| 535 LOG(INFO) << "did navigate"; |
535 gfx::Rect bounds = browser()->window()->GetBounds(); | 536 gfx::Rect bounds = browser()->window()->GetBounds(); |
536 gfx::Rect new_bounds = bounds; | 537 gfx::Rect new_bounds = bounds; |
537 | 538 |
538 const char* create_event = "IOSurfaceImageTransportSurface::CreateIOSurface"; | 539 const char* create_event = "IOSurfaceImageTransportSurface::CreateIOSurface"; |
539 const char* resize_event = "IOSurfaceImageTransportSurface::OnResize"; | 540 const char* resize_event = "IOSurfaceImageTransportSurface::OnResize"; |
540 const char* draw_event = "CompositingIOSurfaceMac::DrawIOSurface"; | 541 const char* draw_event = "CompositingIOSurfaceMac::DrawIOSurface"; |
541 Query find_creates = Query::MatchBeginName(create_event); | 542 Query find_creates = Query::MatchBeginName(create_event); |
542 Query find_resizes = Query::MatchBeginName(resize_event) && | 543 Query find_resizes = Query::MatchBeginName(resize_event) && |
543 Query::EventHasNumberArg("old_width") && | 544 Query::EventHasNumberArg("old_width") && |
544 Query::EventHasNumberArg("new_width"); | 545 Query::EventHasNumberArg("new_width"); |
545 Query find_draws = Query::MatchBeginName(draw_event) && | 546 Query find_draws = Query::MatchBeginName(draw_event) && |
546 Query::EventHasNumberArg("scale"); | 547 Query::EventHasNumberArg("scale"); |
547 | 548 |
548 const int roundup = 64; | 549 const int roundup = 64; |
549 // A few resize values assuming a roundup of 64 pixels. The test will resize | 550 // A few resize values assuming a roundup of 64 pixels. The test will resize |
550 // by these values one at a time and verify that CreateIOSurface only happens | 551 // by these values one at a time and verify that CreateIOSurface only happens |
551 // when the rounded width changes. | 552 // when the rounded width changes. |
552 int offsets[] = { 1, roundup - 1, roundup, roundup + 1, 2*roundup}; | 553 int offsets[] = { 1, roundup - 1, roundup, roundup + 1, 2*roundup}; |
553 int num_offsets = static_cast<int>(arraysize(offsets)); | 554 int num_offsets = static_cast<int>(arraysize(offsets)); |
554 int w_start = bounds.width(); | 555 int w_start = bounds.width(); |
555 | 556 |
556 for (int offset_i = 0; offset_i < num_offsets; ++offset_i) { | 557 for (int offset_i = 0; offset_i < num_offsets; ++offset_i) { |
557 new_bounds.set_width(w_start + offsets[offset_i]); | 558 new_bounds.set_width(w_start + offsets[offset_i]); |
| 559 LOG(INFO) << "before wait"; |
558 ASSERT_TRUE(ResizeAndWait(new_bounds, "gpu", "gpu", resize_event)); | 560 ASSERT_TRUE(ResizeAndWait(new_bounds, "gpu", "gpu", resize_event)); |
| 561 LOG(INFO) << "after wait"; |
559 | 562 |
560 TraceEventVector resize_events; | 563 TraceEventVector resize_events; |
561 analyzer_->FindEvents(find_resizes, &resize_events); | 564 analyzer_->FindEvents(find_resizes, &resize_events); |
| 565 LOG(INFO) << "num rezize events = " << resize_events.size(); |
562 for (size_t resize_i = 0; resize_i < resize_events.size(); ++resize_i) { | 566 for (size_t resize_i = 0; resize_i < resize_events.size(); ++resize_i) { |
563 const trace_analyzer::TraceEvent* resize = resize_events[resize_i]; | 567 const trace_analyzer::TraceEvent* resize = resize_events[resize_i]; |
564 // Was a create allowed: | 568 // Was a create allowed: |
565 int old_width = resize->GetKnownArgAsInt("old_width"); | 569 int old_width = resize->GetKnownArgAsInt("old_width"); |
566 int new_width = resize->GetKnownArgAsInt("new_width"); | 570 int new_width = resize->GetKnownArgAsInt("new_width"); |
567 bool expect_create = (old_width/roundup != new_width/roundup || | 571 bool expect_create = (old_width/roundup != new_width/roundup || |
568 old_width == 0); | 572 old_width == 0); |
569 int expected_creates = expect_create ? 1 : 0; | 573 int expected_creates = expect_create ? 1 : 0; |
570 | 574 |
571 // Find the create event inside this resize event (if any). This will | 575 // Find the create event inside this resize event (if any). This will |
572 // determine if the resize triggered a reallocation of the IOSurface. | 576 // determine if the resize triggered a reallocation of the IOSurface. |
573 double begin_time = resize->timestamp; | 577 double begin_time = resize->timestamp; |
574 double end_time = begin_time + resize->GetAbsTimeToOtherEvent(); | 578 double end_time = begin_time + resize->GetAbsTimeToOtherEvent(); |
575 Query find_this_create = find_creates && | 579 Query find_this_create = find_creates && |
576 Query::EventTime() >= Query::Double(begin_time) && | 580 Query::EventTime() >= Query::Double(begin_time) && |
577 Query::EventTime() <= Query::Double(end_time); | 581 Query::EventTime() <= Query::Double(end_time); |
578 TraceEventVector create_events; | 582 TraceEventVector create_events; |
579 int num_creates = static_cast<int>(analyzer_->FindEvents(find_this_create, | 583 int num_creates = static_cast<int>(analyzer_->FindEvents(find_this_create, |
580 &create_events)); | 584 &create_events)); |
581 EXPECT_EQ(expected_creates, num_creates); | 585 EXPECT_EQ(expected_creates, num_creates); |
582 | 586 |
583 // For debugging failures, print out the width and height of each resize: | 587 // For debugging failures, print out the width and height of each resize: |
584 LOG(INFO) << | 588 LOG(INFO) << |
585 base::StringPrintf( | 589 base::StringPrintf( |
586 "%d (resize offset %d): IOSurface width %d -> %d; Creates %d " | 590 "%d (resize offset %d): IOSurface width %d -> %d; Creates %d " |
587 "Expected %d", offset_i, offsets[offset_i], | 591 "Expected %d", offset_i, offsets[offset_i], |
588 old_width, new_width, num_creates, expected_creates); | 592 old_width, new_width, num_creates, expected_creates); |
589 } | 593 } |
590 } | 594 } |
| 595 LOG(INFO) << "finished test"; |
591 } | 596 } |
592 #endif | 597 #endif |
593 | 598 |
594 } // namespace | 599 } // namespace |
OLD | NEW |