2024-01-25 15:38:38 +08:00
|
|
|
#include <gtest/gtest.h>
|
|
|
|
#include <cdroid.h>
|
|
|
|
#include <ngl_os.h>
|
|
|
|
#include <view/velocitytracker.h>
|
|
|
|
using namespace cdroid;
|
|
|
|
|
|
|
|
class VELOCITY:public testing::Test{
|
|
|
|
|
|
|
|
public :
|
|
|
|
virtual void SetUp(){
|
|
|
|
}
|
|
|
|
virtual void TearDown(){
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
TEST_F(VELOCITY,test1){
|
|
|
|
VelocityTracker*vc =VelocityTracker::obtain();
|
|
|
|
nsecs_t etime = SystemClock::uptimeMillis();
|
|
|
|
for(int i=0,y=0;i<10;i++){
|
|
|
|
MotionEvent*e=MotionEvent::obtain(etime,etime,MotionEvent::ACTION_MOVE,0,y,0);
|
|
|
|
vc->addMovement(*e);
|
|
|
|
etime+=10;
|
|
|
|
y+=10;
|
|
|
|
}
|
|
|
|
vc->computeCurrentVelocity(1000,8000.0f);
|
|
|
|
int velocity=vc->getYVelocity(0);
|
2024-01-31 23:38:38 +08:00
|
|
|
printf("velocity=%d\r\n",velocity);
|
2024-01-25 15:38:38 +08:00
|
|
|
}
|