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 "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 "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/memory/shared_memory.h" | 8 #include "base/memory/shared_memory.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 gfx::Point(20, 20), | 409 gfx::Point(20, 20), |
410 0, | 410 0, |
411 ui::EventTimeForNow()); | 411 ui::EventTimeForNow()); |
412 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, | 412 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, |
413 gfx::Point(20, 20), | 413 gfx::Point(20, 20), |
414 0, | 414 0, |
415 ui::EventTimeForNow()); | 415 ui::EventTimeForNow()); |
416 | 416 |
417 view_->OnTouchEvent(&press); | 417 view_->OnTouchEvent(&press); |
418 EXPECT_FALSE(press.handled()); | 418 EXPECT_FALSE(press.handled()); |
419 EXPECT_EQ(WebKit::WebInputEvent::TouchStart, view_->touch_event_.type); | 419 EXPECT_EQ(blink::WebInputEvent::TouchStart, view_->touch_event_.type); |
420 EXPECT_EQ(1U, view_->touch_event_.touchesLength); | 420 EXPECT_EQ(1U, view_->touch_event_.touchesLength); |
421 EXPECT_EQ(WebKit::WebTouchPoint::StatePressed, | 421 EXPECT_EQ(blink::WebTouchPoint::StatePressed, |
422 view_->touch_event_.touches[0].state); | 422 view_->touch_event_.touches[0].state); |
423 | 423 |
424 view_->OnTouchEvent(&move); | 424 view_->OnTouchEvent(&move); |
425 EXPECT_FALSE(move.handled()); | 425 EXPECT_FALSE(move.handled()); |
426 EXPECT_EQ(WebKit::WebInputEvent::TouchMove, view_->touch_event_.type); | 426 EXPECT_EQ(blink::WebInputEvent::TouchMove, view_->touch_event_.type); |
427 EXPECT_EQ(1U, view_->touch_event_.touchesLength); | 427 EXPECT_EQ(1U, view_->touch_event_.touchesLength); |
428 EXPECT_EQ(WebKit::WebTouchPoint::StateMoved, | 428 EXPECT_EQ(blink::WebTouchPoint::StateMoved, |
429 view_->touch_event_.touches[0].state); | 429 view_->touch_event_.touches[0].state); |
430 | 430 |
431 view_->OnTouchEvent(&release); | 431 view_->OnTouchEvent(&release); |
432 EXPECT_FALSE(release.handled()); | 432 EXPECT_FALSE(release.handled()); |
433 EXPECT_EQ(WebKit::WebInputEvent::TouchEnd, view_->touch_event_.type); | 433 EXPECT_EQ(blink::WebInputEvent::TouchEnd, view_->touch_event_.type); |
434 EXPECT_EQ(0U, view_->touch_event_.touchesLength); | 434 EXPECT_EQ(0U, view_->touch_event_.touchesLength); |
435 | 435 |
436 // Now install some touch-event handlers and do the same steps. The touch | 436 // Now install some touch-event handlers and do the same steps. The touch |
437 // events should now be consumed. However, the touch-event state should be | 437 // events should now be consumed. However, the touch-event state should be |
438 // updated as before. | 438 // updated as before. |
439 widget_host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, true)); | 439 widget_host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, true)); |
440 EXPECT_TRUE(widget_host_->ShouldForwardTouchEvent()); | 440 EXPECT_TRUE(widget_host_->ShouldForwardTouchEvent()); |
441 | 441 |
442 view_->OnTouchEvent(&press); | 442 view_->OnTouchEvent(&press); |
443 EXPECT_TRUE(press.stopped_propagation()); | 443 EXPECT_TRUE(press.stopped_propagation()); |
444 EXPECT_EQ(WebKit::WebInputEvent::TouchStart, view_->touch_event_.type); | 444 EXPECT_EQ(blink::WebInputEvent::TouchStart, view_->touch_event_.type); |
445 EXPECT_EQ(1U, view_->touch_event_.touchesLength); | 445 EXPECT_EQ(1U, view_->touch_event_.touchesLength); |
446 EXPECT_EQ(WebKit::WebTouchPoint::StatePressed, | 446 EXPECT_EQ(blink::WebTouchPoint::StatePressed, |
447 view_->touch_event_.touches[0].state); | 447 view_->touch_event_.touches[0].state); |
448 | 448 |
449 view_->OnTouchEvent(&move); | 449 view_->OnTouchEvent(&move); |
450 EXPECT_TRUE(move.stopped_propagation()); | 450 EXPECT_TRUE(move.stopped_propagation()); |
451 EXPECT_EQ(WebKit::WebInputEvent::TouchMove, view_->touch_event_.type); | 451 EXPECT_EQ(blink::WebInputEvent::TouchMove, view_->touch_event_.type); |
452 EXPECT_EQ(1U, view_->touch_event_.touchesLength); | 452 EXPECT_EQ(1U, view_->touch_event_.touchesLength); |
453 EXPECT_EQ(WebKit::WebTouchPoint::StateMoved, | 453 EXPECT_EQ(blink::WebTouchPoint::StateMoved, |
454 view_->touch_event_.touches[0].state); | 454 view_->touch_event_.touches[0].state); |
455 | 455 |
456 view_->OnTouchEvent(&release); | 456 view_->OnTouchEvent(&release); |
457 EXPECT_TRUE(release.stopped_propagation()); | 457 EXPECT_TRUE(release.stopped_propagation()); |
458 EXPECT_EQ(WebKit::WebInputEvent::TouchEnd, view_->touch_event_.type); | 458 EXPECT_EQ(blink::WebInputEvent::TouchEnd, view_->touch_event_.type); |
459 EXPECT_EQ(0U, view_->touch_event_.touchesLength); | 459 EXPECT_EQ(0U, view_->touch_event_.touchesLength); |
460 | 460 |
461 // Now start a touch event, and remove the event-handlers before the release. | 461 // Now start a touch event, and remove the event-handlers before the release. |
462 view_->OnTouchEvent(&press); | 462 view_->OnTouchEvent(&press); |
463 EXPECT_TRUE(press.stopped_propagation()); | 463 EXPECT_TRUE(press.stopped_propagation()); |
464 EXPECT_EQ(WebKit::WebInputEvent::TouchStart, view_->touch_event_.type); | 464 EXPECT_EQ(blink::WebInputEvent::TouchStart, view_->touch_event_.type); |
465 EXPECT_EQ(1U, view_->touch_event_.touchesLength); | 465 EXPECT_EQ(1U, view_->touch_event_.touchesLength); |
466 EXPECT_EQ(WebKit::WebTouchPoint::StatePressed, | 466 EXPECT_EQ(blink::WebTouchPoint::StatePressed, |
467 view_->touch_event_.touches[0].state); | 467 view_->touch_event_.touches[0].state); |
468 | 468 |
469 widget_host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, false)); | 469 widget_host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, false)); |
470 EXPECT_FALSE(widget_host_->ShouldForwardTouchEvent()); | 470 EXPECT_FALSE(widget_host_->ShouldForwardTouchEvent()); |
471 | 471 |
472 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(20, 20), 0, | 472 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(20, 20), 0, |
473 base::Time::NowFromSystemTime() - base::Time()); | 473 base::Time::NowFromSystemTime() - base::Time()); |
474 view_->OnTouchEvent(&move2); | 474 view_->OnTouchEvent(&move2); |
475 EXPECT_FALSE(move2.handled()); | 475 EXPECT_FALSE(move2.handled()); |
476 EXPECT_EQ(WebKit::WebInputEvent::TouchMove, view_->touch_event_.type); | 476 EXPECT_EQ(blink::WebInputEvent::TouchMove, view_->touch_event_.type); |
477 EXPECT_EQ(1U, view_->touch_event_.touchesLength); | 477 EXPECT_EQ(1U, view_->touch_event_.touchesLength); |
478 EXPECT_EQ(WebKit::WebTouchPoint::StateMoved, | 478 EXPECT_EQ(blink::WebTouchPoint::StateMoved, |
479 view_->touch_event_.touches[0].state); | 479 view_->touch_event_.touches[0].state); |
480 | 480 |
481 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(20, 20), 0, | 481 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(20, 20), 0, |
482 base::Time::NowFromSystemTime() - base::Time()); | 482 base::Time::NowFromSystemTime() - base::Time()); |
483 view_->OnTouchEvent(&release2); | 483 view_->OnTouchEvent(&release2); |
484 EXPECT_FALSE(release2.handled()); | 484 EXPECT_FALSE(release2.handled()); |
485 EXPECT_EQ(WebKit::WebInputEvent::TouchEnd, view_->touch_event_.type); | 485 EXPECT_EQ(blink::WebInputEvent::TouchEnd, view_->touch_event_.type); |
486 EXPECT_EQ(0U, view_->touch_event_.touchesLength); | 486 EXPECT_EQ(0U, view_->touch_event_.touchesLength); |
487 } | 487 } |
488 | 488 |
489 // Checks that touch-events are queued properly when there is a touch-event | 489 // Checks that touch-events are queued properly when there is a touch-event |
490 // handler on the page. | 490 // handler on the page. |
491 TEST_F(RenderWidgetHostViewAuraTest, TouchEventSyncAsync) { | 491 TEST_F(RenderWidgetHostViewAuraTest, TouchEventSyncAsync) { |
492 view_->InitAsChild(NULL); | 492 view_->InitAsChild(NULL); |
493 view_->Show(); | 493 view_->Show(); |
494 | 494 |
495 widget_host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, true)); | 495 widget_host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, true)); |
496 EXPECT_TRUE(widget_host_->ShouldForwardTouchEvent()); | 496 EXPECT_TRUE(widget_host_->ShouldForwardTouchEvent()); |
497 | 497 |
498 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, | 498 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, |
499 gfx::Point(30, 30), | 499 gfx::Point(30, 30), |
500 0, | 500 0, |
501 ui::EventTimeForNow()); | 501 ui::EventTimeForNow()); |
502 ui::TouchEvent move(ui::ET_TOUCH_MOVED, | 502 ui::TouchEvent move(ui::ET_TOUCH_MOVED, |
503 gfx::Point(20, 20), | 503 gfx::Point(20, 20), |
504 0, | 504 0, |
505 ui::EventTimeForNow()); | 505 ui::EventTimeForNow()); |
506 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, | 506 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, |
507 gfx::Point(20, 20), | 507 gfx::Point(20, 20), |
508 0, | 508 0, |
509 ui::EventTimeForNow()); | 509 ui::EventTimeForNow()); |
510 | 510 |
511 view_->OnTouchEvent(&press); | 511 view_->OnTouchEvent(&press); |
512 EXPECT_TRUE(press.stopped_propagation()); | 512 EXPECT_TRUE(press.stopped_propagation()); |
513 EXPECT_EQ(WebKit::WebInputEvent::TouchStart, view_->touch_event_.type); | 513 EXPECT_EQ(blink::WebInputEvent::TouchStart, view_->touch_event_.type); |
514 EXPECT_EQ(1U, view_->touch_event_.touchesLength); | 514 EXPECT_EQ(1U, view_->touch_event_.touchesLength); |
515 EXPECT_EQ(WebKit::WebTouchPoint::StatePressed, | 515 EXPECT_EQ(blink::WebTouchPoint::StatePressed, |
516 view_->touch_event_.touches[0].state); | 516 view_->touch_event_.touches[0].state); |
517 | 517 |
518 view_->OnTouchEvent(&move); | 518 view_->OnTouchEvent(&move); |
519 EXPECT_TRUE(move.stopped_propagation()); | 519 EXPECT_TRUE(move.stopped_propagation()); |
520 EXPECT_EQ(WebKit::WebInputEvent::TouchMove, view_->touch_event_.type); | 520 EXPECT_EQ(blink::WebInputEvent::TouchMove, view_->touch_event_.type); |
521 EXPECT_EQ(1U, view_->touch_event_.touchesLength); | 521 EXPECT_EQ(1U, view_->touch_event_.touchesLength); |
522 EXPECT_EQ(WebKit::WebTouchPoint::StateMoved, | 522 EXPECT_EQ(blink::WebTouchPoint::StateMoved, |
523 view_->touch_event_.touches[0].state); | 523 view_->touch_event_.touches[0].state); |
524 | 524 |
525 // Send the same move event. Since the point hasn't moved, it won't affect the | 525 // Send the same move event. Since the point hasn't moved, it won't affect the |
526 // queue. However, the view should consume the event. | 526 // queue. However, the view should consume the event. |
527 view_->OnTouchEvent(&move); | 527 view_->OnTouchEvent(&move); |
528 EXPECT_TRUE(move.stopped_propagation()); | 528 EXPECT_TRUE(move.stopped_propagation()); |
529 EXPECT_EQ(WebKit::WebInputEvent::TouchMove, view_->touch_event_.type); | 529 EXPECT_EQ(blink::WebInputEvent::TouchMove, view_->touch_event_.type); |
530 EXPECT_EQ(1U, view_->touch_event_.touchesLength); | 530 EXPECT_EQ(1U, view_->touch_event_.touchesLength); |
531 EXPECT_EQ(WebKit::WebTouchPoint::StateMoved, | 531 EXPECT_EQ(blink::WebTouchPoint::StateMoved, |
532 view_->touch_event_.touches[0].state); | 532 view_->touch_event_.touches[0].state); |
533 | 533 |
534 view_->OnTouchEvent(&release); | 534 view_->OnTouchEvent(&release); |
535 EXPECT_TRUE(release.stopped_propagation()); | 535 EXPECT_TRUE(release.stopped_propagation()); |
536 EXPECT_EQ(WebKit::WebInputEvent::TouchEnd, view_->touch_event_.type); | 536 EXPECT_EQ(blink::WebInputEvent::TouchEnd, view_->touch_event_.type); |
537 EXPECT_EQ(0U, view_->touch_event_.touchesLength); | 537 EXPECT_EQ(0U, view_->touch_event_.touchesLength); |
538 } | 538 } |
539 | 539 |
540 TEST_F(RenderWidgetHostViewAuraTest, PhysicalBackingSizeWithScale) { | 540 TEST_F(RenderWidgetHostViewAuraTest, PhysicalBackingSizeWithScale) { |
541 view_->InitAsChild(NULL); | 541 view_->InitAsChild(NULL); |
542 aura::client::ParentWindowWithContext( | 542 aura::client::ParentWindowWithContext( |
543 view_->GetNativeView(), | 543 view_->GetNativeView(), |
544 parent_view_->GetNativeView()->GetRootWindow(), | 544 parent_view_->GetNativeView()->GetRootWindow(), |
545 gfx::Rect()); | 545 gfx::Rect()); |
546 sink_->ClearMessages(); | 546 sink_->ClearMessages(); |
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1072 views[0]->WasHidden(); | 1072 views[0]->WasHidden(); |
1073 EXPECT_FALSE(views[0]->frame_provider_); | 1073 EXPECT_FALSE(views[0]->frame_provider_); |
1074 | 1074 |
1075 for (size_t i = 0; i < renderer_count; ++i) { | 1075 for (size_t i = 0; i < renderer_count; ++i) { |
1076 views[i]->Destroy(); | 1076 views[i]->Destroy(); |
1077 delete hosts[i]; | 1077 delete hosts[i]; |
1078 } | 1078 } |
1079 } | 1079 } |
1080 | 1080 |
1081 } // namespace content | 1081 } // namespace content |
OLD | NEW |