X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit%2Futc-Dali-WebView.cpp;h=0ca47b671c15f1b450f01bc41d034386eb8c673f;hb=1a0dc2cc53708bbc32546da6031e996465544f51;hp=9221ea5601b90f6e6c2c2d4d45b0473228968039;hpb=ad110f27c01af7e617df158891eef5cf60bf22e6;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/automated-tests/src/dali-toolkit/utc-Dali-WebView.cpp b/automated-tests/src/dali-toolkit/utc-Dali-WebView.cpp index 9221ea5..0ca47b6 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-WebView.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-WebView.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,6 +39,7 @@ const char* const TEST_URL2( "http://www.somewhere.valid2.com" ); static int gPageLoadStartedCallbackCalled = 0; static int gPageLoadFinishedCallbackCalled = 0; +static int gScrollEdgeReachedCallbackCalled = 0; static int gEvaluateJavaScriptCallbackCalled = 0; static bool gTouched = false; @@ -66,6 +67,11 @@ static void OnPageLoadFinished( WebView view, const std::string& url ) gPageLoadFinishedCallbackCalled++; } +static void OnScrollEdgeReached( WebView view, Dali::WebEnginePlugin::ScrollEdge edge ) +{ + gScrollEdgeReachedCallbackCalled++; +} + static void OnPageLoadError( WebView view, const std::string& url, WebView::LoadErrorCode errorCode ) { } @@ -75,7 +81,7 @@ static void OnEvaluateJavaScript( const std::string& result ) gEvaluateJavaScriptCallbackCalled++; } -static bool OnTouched( Actor actor, const Dali::TouchData& touch ) +static bool OnTouched( Actor actor, const Dali::TouchEvent& touch ) { gTouched = true; return true; @@ -148,7 +154,7 @@ int UtcDaliWebViewPageNavigation(void) view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT ); view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 )); view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) ); - Stage::GetCurrent().Add( view ); + application.GetScene().Add( view ); application.SendNotification(); application.Render(); DALI_TEST_CHECK( view ); @@ -220,12 +226,12 @@ int UtcDaliWebViewTouchAndKeys(void) view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 )); view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) ); - Stage::GetCurrent().Add( view ); + application.GetScene().Add( view ); application.SendNotification(); application.Render(); view.GetNaturalSize(); - view.TouchSignal().Connect( &OnTouched ); + view.TouchedSignal().Connect( &OnTouched ); // Touch event Dali::Integration::TouchEvent event; @@ -245,7 +251,7 @@ int UtcDaliWebViewTouchAndKeys(void) // Key event Toolkit::KeyboardFocusManager::Get().SetCurrentFocusActor( view ); - application.ProcessEvent( Integration::KeyEvent( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Down, "", "", Device::Class::NONE, Device::Subclass::NONE ) ); + application.ProcessEvent( Integration::KeyEvent( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", "", Device::Class::NONE, Device::Subclass::NONE ) ); application.SendNotification(); DALI_TEST_CHECK( gTouched ); @@ -254,6 +260,32 @@ int UtcDaliWebViewTouchAndKeys(void) END_TEST; } +int UtcDaliWebViewFocusGainedAndLost(void) +{ + ToolkitTestApplication application; + + WebView view = WebView::New(); + DALI_TEST_CHECK( view ); + + view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT ); + view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT ); + view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 )); + view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) ); + + application.GetScene().Add( view ); + application.SendNotification(); + application.Render(); + + view.SetKeyInputFocus(); + DALI_TEST_CHECK( view.HasKeyInputFocus() ); + + // reset + view.ClearKeyInputFocus(); + DALI_TEST_CHECK( !view.HasKeyInputFocus() ); + + END_TEST; +} + int UtcDaliWebViewProperty1(void) { // URL @@ -465,6 +497,72 @@ int UtcDaliWebViewProperty8(void) END_TEST; } +int UtcDaliWebViewProperty9(void) +{ + // SCROLL_POSITION + ToolkitTestApplication application; + + WebView view = WebView::New(); + DALI_TEST_CHECK( view ); + + // Check default value + Dali::Vector2 output = Dali::Vector2::ONE; + view.GetProperty( WebView::Property::SCROLL_POSITION ).Get( output ); + DALI_TEST_CHECK( output.x == 0 && output.y == 0 ); + + // Check Set/GetProperty + Dali::Vector2 testValue = Dali::Vector2( 100, 100 ); + view.SetProperty( WebView::Property::SCROLL_POSITION, testValue ); + view.GetProperty( WebView::Property::SCROLL_POSITION ).Get( output ); + DALI_TEST_EQUALS( output, testValue, TEST_LOCATION ); + + // Check default value of scroll size + output = Dali::Vector2::ONE; + view.GetProperty( WebView::Property::SCROLL_SIZE ).Get( output ); + DALI_TEST_CHECK( output.x == 500 && output.y == 500 ); + + // Check default value of content size + output = Dali::Vector2::ONE; + view.GetProperty( WebView::Property::CONTENT_SIZE ).Get( output ); + DALI_TEST_CHECK( output.x == 500 && output.y == 500 ); + + END_TEST; +} + +int UtcDaliWebViewScrollBy(void) +{ + ToolkitTestApplication application; + + WebView view = WebView::New(); + DALI_TEST_CHECK( view ); + + // load url. + ConnectionTracker* testTracker = new ConnectionTracker(); + view.ScrollEdgeReachedSignal().Connect( &OnScrollEdgeReached ); + bool signal1 = false; + view.ConnectSignal( testTracker, "scrollEdgeReached", CallbackFunctor(&signal1) ); + DALI_TEST_EQUALS( gScrollEdgeReachedCallbackCalled, 0, TEST_LOCATION ); + + view.LoadUrl( TEST_URL1 ); + Test::EmitGlobalTimerSignal(); + + // set scroll position. + Dali::Vector2 output = Dali::Vector2::ONE; + Dali::Vector2 testValue = Dali::Vector2( 100, 100 ); + view.SetProperty( WebView::Property::SCROLL_POSITION, testValue ); + view.GetProperty( WebView::Property::SCROLL_POSITION ).Get( output ); + DALI_TEST_EQUALS( output, testValue, TEST_LOCATION ); + + // scroll by and trigger scrollEdgeReached event. + view.ScrollBy( 50, 50 ); + view.GetProperty( WebView::Property::SCROLL_POSITION ).Get( output ); + DALI_TEST_CHECK( output.x == 150 && output.y == 150 ); + DALI_TEST_EQUALS( gScrollEdgeReachedCallbackCalled, 1, TEST_LOCATION ); + DALI_TEST_CHECK( signal1 ); + + END_TEST; +} + int UtcDaliWebViewEvaluteJavaScript(void) { ToolkitTestApplication application;