Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(933)

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_aura_unittest.cc

Issue 2393783005: re-land the "SourceEventType added to LatencyInfo." (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "content/browser/renderer_host/render_widget_host_view_aura.h" 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <tuple> 10 #include <tuple>
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 private: 428 private:
429 aura::Window* owner_; 429 aura::Window* owner_;
430 DISALLOW_COPY_AND_ASSIGN(FullscreenLayoutManager); 430 DISALLOW_COPY_AND_ASSIGN(FullscreenLayoutManager);
431 }; 431 };
432 432
433 class MockWindowObserver : public aura::WindowObserver { 433 class MockWindowObserver : public aura::WindowObserver {
434 public: 434 public:
435 MOCK_METHOD2(OnDelegatedFrameDamage, void(aura::Window*, const gfx::Rect&)); 435 MOCK_METHOD2(OnDelegatedFrameDamage, void(aura::Window*, const gfx::Rect&));
436 }; 436 };
437 437
438 class MockRenderWidgetHostImpl : public RenderWidgetHostImpl {
439 public:
440 MockRenderWidgetHostImpl(RenderWidgetHostDelegate* delegate,
441 RenderProcessHost* process,
442 int32_t routing_id)
443 : RenderWidgetHostImpl(delegate, process, routing_id, false) {
444 set_renderer_initialized(true);
445 lastWheelOrTouchEventLatencyInfo = ui::LatencyInfo();
446 }
447
448 // Extracts |latency_info| for wheel event, and stores it in
449 // |lastWheelOrTouchEventLatencyInfo|.
450 void ForwardWheelEventWithLatencyInfo(
451 const blink::WebMouseWheelEvent& wheel_event,
452 const ui::LatencyInfo& ui_latency) override {
453 RenderWidgetHostImpl::ForwardWheelEventWithLatencyInfo(wheel_event,
454 ui_latency);
455 lastWheelOrTouchEventLatencyInfo = ui::LatencyInfo(ui_latency);
456 }
457
458 // Extracts |latency_info| for touch event, and stores it in
459 // |lastWheelOrTouchEventLatencyInfo|.
460 void ForwardTouchEventWithLatencyInfo(
461 const blink::WebTouchEvent& touch_event,
462 const ui::LatencyInfo& ui_latency) override {
463 RenderWidgetHostImpl::ForwardTouchEventWithLatencyInfo(touch_event,
464 ui_latency);
465 lastWheelOrTouchEventLatencyInfo = ui::LatencyInfo(ui_latency);
466 }
467
468 ui::LatencyInfo lastWheelOrTouchEventLatencyInfo;
469 };
470
438 const WebInputEvent* GetInputEventFromMessage(const IPC::Message& message) { 471 const WebInputEvent* GetInputEventFromMessage(const IPC::Message& message) {
439 base::PickleIterator iter(message); 472 base::PickleIterator iter(message);
440 const char* data; 473 const char* data;
441 int data_length; 474 int data_length;
442 if (!iter.ReadData(&data, &data_length)) 475 if (!iter.ReadData(&data, &data_length))
443 return nullptr; 476 return nullptr;
444 return reinterpret_cast<const WebInputEvent*>(data); 477 return reinterpret_cast<const WebInputEvent*>(data);
445 } 478 }
446 479
447 } // namespace 480 } // namespace
(...skipping 27 matching lines...) Expand all
475 delegates_.back()->set_widget_host(parent_host_); 508 delegates_.back()->set_widget_host(parent_host_);
476 parent_view_ = new RenderWidgetHostViewAura(parent_host_, 509 parent_view_ = new RenderWidgetHostViewAura(parent_host_,
477 is_guest_view_hack_); 510 is_guest_view_hack_);
478 parent_view_->InitAsChild(nullptr); 511 parent_view_->InitAsChild(nullptr);
479 aura::client::ParentWindowWithContext(parent_view_->GetNativeView(), 512 aura::client::ParentWindowWithContext(parent_view_->GetNativeView(),
480 aura_test_helper_->root_window(), 513 aura_test_helper_->root_window(),
481 gfx::Rect()); 514 gfx::Rect());
482 515
483 routing_id = process_host_->GetNextRoutingID(); 516 routing_id = process_host_->GetNextRoutingID();
484 delegates_.push_back(base::WrapUnique(new MockRenderWidgetHostDelegate)); 517 delegates_.push_back(base::WrapUnique(new MockRenderWidgetHostDelegate));
485 widget_host_ = new RenderWidgetHostImpl(delegates_.back().get(), 518 widget_host_ = new MockRenderWidgetHostImpl(delegates_.back().get(),
486 process_host_, routing_id, false); 519 process_host_, routing_id);
487 delegates_.back()->set_widget_host(widget_host_); 520 delegates_.back()->set_widget_host(widget_host_);
488 widget_host_->Init(); 521 widget_host_->Init();
489 view_ = new FakeRenderWidgetHostViewAura(widget_host_, is_guest_view_hack_); 522 view_ = new FakeRenderWidgetHostViewAura(widget_host_, is_guest_view_hack_);
490 } 523 }
491 524
492 void TearDownEnvironment() { 525 void TearDownEnvironment() {
493 sink_ = nullptr; 526 sink_ = nullptr;
494 process_host_ = nullptr; 527 process_host_ = nullptr;
495 if (view_) { 528 if (view_) {
496 // For guest-views, |view_| is not the view used by |widget_host_|. 529 // For guest-views, |view_| is not the view used by |widget_host_|.
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 std::vector<std::unique_ptr<MockRenderWidgetHostDelegate>> delegates_; 669 std::vector<std::unique_ptr<MockRenderWidgetHostDelegate>> delegates_;
637 MockRenderProcessHost* process_host_; 670 MockRenderProcessHost* process_host_;
638 671
639 // Tests should set these to nullptr if they've already triggered their 672 // Tests should set these to nullptr if they've already triggered their
640 // destruction. 673 // destruction.
641 RenderWidgetHostImpl* parent_host_; 674 RenderWidgetHostImpl* parent_host_;
642 RenderWidgetHostViewAura* parent_view_; 675 RenderWidgetHostViewAura* parent_view_;
643 676
644 // Tests should set these to nullptr if they've already triggered their 677 // Tests should set these to nullptr if they've already triggered their
645 // destruction. 678 // destruction.
646 RenderWidgetHostImpl* widget_host_; 679 MockRenderWidgetHostImpl* widget_host_;
647 FakeRenderWidgetHostViewAura* view_; 680 FakeRenderWidgetHostViewAura* view_;
648 681
649 IPC::TestSink* sink_; 682 IPC::TestSink* sink_;
650 683
651 private: 684 private:
652 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAuraTest); 685 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAuraTest);
653 }; 686 };
654 687
655 // Helper class to instantiate RenderWidgetHostViewGuest which is backed 688 // Helper class to instantiate RenderWidgetHostViewGuest which is backed
656 // by an aura platform view. 689 // by an aura platform view.
(...skipping 1851 matching lines...) Expand 10 before | Expand all | Expand 10 after
2508 // scale on it. 2541 // scale on it.
2509 view_->OnSwapCompositorFrame( 2542 view_->OnSwapCompositorFrame(
2510 1, MakeDelegatedFrame(2.f, frame_size, gfx::Rect(frame_size))); 2543 1, MakeDelegatedFrame(2.f, frame_size, gfx::Rect(frame_size)));
2511 2544
2512 // When we get a new frame with the same frame size in physical pixels, but 2545 // When we get a new frame with the same frame size in physical pixels, but
2513 // a different scale, we should generate a surface, as the final result will 2546 // a different scale, we should generate a surface, as the final result will
2514 // need to be scaled differently to the screen. 2547 // need to be scaled differently to the screen.
2515 EXPECT_NE(surface_id, view_->surface_id()); 2548 EXPECT_NE(surface_id, view_->surface_id());
2516 } 2549 }
2517 2550
2551 TEST_F(RenderWidgetHostViewAuraTest, SourceEventTypeExistsInLatencyInfo) {
2552 // WHEEL source exists.
2553 ui::ScrollEvent scroll(ui::ET_SCROLL, gfx::Point(2, 2), ui::EventTimeForNow(),
2554 0, 0, 0, 0, 0, 2);
2555 view_->OnScrollEvent(&scroll);
2556 EXPECT_EQ(widget_host_->lastWheelOrTouchEventLatencyInfo.source_event_type(),
2557 ui::SourceEventType::WHEEL);
2558
2559 // TOUCH source exists.
2560 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(30, 30), 0,
2561 ui::EventTimeForNow());
2562 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(20, 20), 0,
2563 ui::EventTimeForNow());
2564 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(20, 20), 0,
2565 ui::EventTimeForNow());
2566 view_->OnTouchEvent(&press);
2567 view_->OnTouchEvent(&move);
2568 EXPECT_EQ(widget_host_->lastWheelOrTouchEventLatencyInfo.source_event_type(),
2569 ui::SourceEventType::TOUCH);
2570 view_->OnTouchEvent(&release);
2571 }
2572
2518 class RenderWidgetHostViewAuraCopyRequestTest 2573 class RenderWidgetHostViewAuraCopyRequestTest
2519 : public RenderWidgetHostViewAuraShutdownTest { 2574 : public RenderWidgetHostViewAuraShutdownTest {
2520 public: 2575 public:
2521 RenderWidgetHostViewAuraCopyRequestTest() 2576 RenderWidgetHostViewAuraCopyRequestTest()
2522 : callback_count_(0), 2577 : callback_count_(0),
2523 result_(false), 2578 result_(false),
2524 frame_subscriber_(nullptr), 2579 frame_subscriber_(nullptr),
2525 tick_clock_(nullptr), 2580 tick_clock_(nullptr),
2526 view_rect_(100, 100) {} 2581 view_rect_(100, 100) {}
2527 2582
(...skipping 2095 matching lines...) Expand 10 before | Expand all | Expand 10 after
4623 4678
4624 // Retrieve the selected text from clipboard and verify it is as expected. 4679 // Retrieve the selected text from clipboard and verify it is as expected.
4625 base::string16 result_text; 4680 base::string16 result_text;
4626 clipboard->ReadText(ui::CLIPBOARD_TYPE_SELECTION, &result_text); 4681 clipboard->ReadText(ui::CLIPBOARD_TYPE_SELECTION, &result_text);
4627 EXPECT_EQ(expected_text, result_text); 4682 EXPECT_EQ(expected_text, result_text);
4628 } 4683 }
4629 } 4684 }
4630 #endif 4685 #endif
4631 4686
4632 } // namespace content 4687 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698