mirror of
https://github.com/opencv/opencv.git
synced 2025-01-18 06:03:15 +08:00
Merge pull request #469 from asmorkalov:android_manager_4number_version
This commit is contained in:
commit
6503836b4d
@ -5,4 +5,3 @@ mkdir -p build_service
|
||||
cd build_service
|
||||
|
||||
cmake -DCMAKE_TOOLCHAIN_FILE=../android.toolchain.cmake -DANDROID_TOOLCHAIN_NAME="arm-linux-androideabi-4.4.3" -DANDROID_STL=stlport_static -DANDROID_STL_FORCE_FEATURES=OFF -DBUILD_ANDROID_SERVICE=ON -DANDROID_SOURCE_TREE=~/Projects/AndroidSource/ServiceStub/ $@ ../..
|
||||
|
||||
|
@ -62,3 +62,14 @@ set_target_properties(${engine}_jni PROPERTIES
|
||||
|
||||
get_target_property(engine_lib_location ${engine}_jni LOCATION)
|
||||
add_custom_command(TARGET ${engine}_jni POST_BUILD COMMAND ${CMAKE_STRIP} --strip-unneeded "${engine_lib_location}")
|
||||
|
||||
# native tests
|
||||
add_definitions(-DGTEST_HAS_CLONE=0 -DANDROID -DGTEST_HAS_TR1_TUPLE=0)
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-allow-shlib-undefined")
|
||||
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/jni/Tests)
|
||||
file(GLOB engine_test_files "jni/Tests/*.cpp")
|
||||
|
||||
add_executable(opencv_test_engine ${engine_test_files} jni/Tests/gtest/gtest-all.cpp)
|
||||
target_link_libraries(opencv_test_engine z binder log utils android_runtime ${engine} ${engine}_jni)
|
||||
|
||||
|
@ -80,17 +80,21 @@ string CommonPackageManager::GetPackagePathByVersion(int version, int platform,
|
||||
|
||||
if (!packages.empty())
|
||||
{
|
||||
int OptRating = -1;
|
||||
int OptVersion = 0;
|
||||
std::vector<std::pair<int, int> >& group = CommonPackageManager::ArmRating;
|
||||
int platform_group = 0;
|
||||
|
||||
if ((cpu_id & ARCH_X86) || (cpu_id & ARCH_X64))
|
||||
group = CommonPackageManager::IntelRating;
|
||||
platform_group = 1;
|
||||
|
||||
int HardwareRating = GetHardwareRating(platform, cpu_id, group);
|
||||
LOGD("Current hardware platform rating %d for (%d,%d)", HardwareRating, platform, cpu_id);
|
||||
if (cpu_id & ARCH_MIPS)
|
||||
platform_group = 2;
|
||||
|
||||
if (-1 == HardwareRating)
|
||||
int opt_rating = -1;
|
||||
int opt_version = 0;
|
||||
|
||||
const int hardware_rating = GetHardwareRating(platform, cpu_id, ArchRatings[platform_group]);
|
||||
LOGD("Current hardware platform rating %d for (%d,%d)", hardware_rating, platform, cpu_id);
|
||||
|
||||
if (-1 == hardware_rating)
|
||||
{
|
||||
LOGE("Cannot calculate rating for current hardware platform!");
|
||||
}
|
||||
@ -99,26 +103,38 @@ string CommonPackageManager::GetPackagePathByVersion(int version, int platform,
|
||||
vector<PackageInfo>::iterator found = packages.end();
|
||||
for (vector<PackageInfo>::iterator it = packages.begin(); it != packages.end(); ++it)
|
||||
{
|
||||
int PackageRating = GetHardwareRating(it->GetPlatform(), it->GetCpuID(), group);
|
||||
LOGD("Package \"%s\" rating %d for (%d,%d)", it->GetFullName().c_str(), PackageRating, it->GetPlatform(), it->GetCpuID());
|
||||
if ((PackageRating >= 0) && (PackageRating <= HardwareRating))
|
||||
int package_group = 0;
|
||||
|
||||
if ((it->GetCpuID() & ARCH_X86) || (it->GetCpuID() & ARCH_X64))
|
||||
package_group = 1;
|
||||
|
||||
if (it->GetCpuID() & ARCH_MIPS)
|
||||
package_group = 2;
|
||||
|
||||
if (package_group != platform_group)
|
||||
continue;
|
||||
|
||||
const int package_rating = GetHardwareRating(it->GetPlatform(), it->GetCpuID(), ArchRatings[package_group]);
|
||||
|
||||
LOGD("Package \"%s\" rating %d for (%d,%d)", it->GetFullName().c_str(), package_rating, it->GetPlatform(), it->GetCpuID());
|
||||
if ((package_rating >= 0) && (package_rating <= hardware_rating))
|
||||
{
|
||||
if (((it->GetVersion() >= OptVersion) && (PackageRating >= OptRating)) || (it->GetVersion() > OptVersion))
|
||||
if (((it->GetVersion() >= opt_version) && (package_rating >= opt_rating)) || (it->GetVersion() > opt_version))
|
||||
{
|
||||
OptRating = PackageRating;
|
||||
OptVersion = it->GetVersion();
|
||||
opt_rating = package_rating;
|
||||
opt_version = it->GetVersion();
|
||||
found = it;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((-1 != OptRating) && (packages.end() != found))
|
||||
if ((-1 != opt_rating) && (packages.end() != found))
|
||||
{
|
||||
result = found->GetInstalationPath();
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGI("Found package is incompatible with current hardware platform");
|
||||
LOGI("No compatible packages found!");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -146,10 +162,13 @@ int CommonPackageManager::GetHardwareRating(int platform, int cpu_id, const std:
|
||||
else
|
||||
{
|
||||
// Calculate rating for Arm
|
||||
LOGD("!!! Calculating rating for ARM\n");
|
||||
for (size_t i = 0; i < group.size(); i++)
|
||||
{
|
||||
LOGD("Checking (%d, %d) against (%d,%d)\n", group[i].first, group[i].second, platform, cpu_id);
|
||||
if (group[i] == std::pair<int, int>(platform, cpu_id))
|
||||
{
|
||||
LOGD("Rating found: %d\n", i);
|
||||
result = i;
|
||||
break;
|
||||
}
|
||||
@ -182,21 +201,27 @@ std::vector<std::pair<int, int> > CommonPackageManager::InitArmRating()
|
||||
return result;
|
||||
}
|
||||
|
||||
// Stub for Intel platforms rating initialization. Common package for all Intel based devices is used now
|
||||
std::vector<std::pair<int, int> > CommonPackageManager::InitIntelRating()
|
||||
{
|
||||
std::vector<std::pair<int, int> > result;
|
||||
|
||||
result.push_back(std::pair<int, int>(PLATFORM_UNKNOWN, ARCH_X64));
|
||||
result.push_back(std::pair<int, int>(PLATFORM_UNKNOWN, ARCH_X86 | FEATURES_HAS_SSSE3));
|
||||
result.push_back(std::pair<int, int>(PLATFORM_UNKNOWN, ARCH_X86 | FEATURES_HAS_SSE2));
|
||||
result.push_back(std::pair<int, int>(PLATFORM_UNKNOWN, ARCH_X86 | FEATURES_HAS_SSE));
|
||||
result.push_back(std::pair<int, int>(PLATFORM_UNKNOWN, ARCH_X86));
|
||||
return result;
|
||||
}
|
||||
|
||||
// Stub for MIPS platforms rating initialization. Common package for all MIPS based devices is used now
|
||||
std::vector<std::pair<int, int> > CommonPackageManager::InitMipsRating()
|
||||
{
|
||||
std::vector<std::pair<int, int> > result;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
std::vector<std::pair<int, int> > CommonPackageManager::IntelRating = CommonPackageManager::InitIntelRating();
|
||||
std::vector<std::pair<int, int> > CommonPackageManager::ArmRating = InitArmRating();
|
||||
const std::vector<std::pair<int, int> > CommonPackageManager::ArchRatings[] = {
|
||||
CommonPackageManager::InitArmRating(),
|
||||
CommonPackageManager::InitIntelRating(),
|
||||
CommonPackageManager::InitMipsRating()
|
||||
};
|
||||
|
||||
CommonPackageManager::~CommonPackageManager()
|
||||
{
|
||||
|
@ -16,11 +16,11 @@ public:
|
||||
virtual ~CommonPackageManager();
|
||||
|
||||
protected:
|
||||
static std::vector<std::pair<int, int> > ArmRating;
|
||||
static std::vector<std::pair<int, int> > IntelRating;
|
||||
static const std::vector<std::pair<int, int> > ArchRatings[];
|
||||
|
||||
static std::vector<std::pair<int, int> > InitArmRating();
|
||||
static std::vector<std::pair<int, int> > InitIntelRating();
|
||||
static std::vector<std::pair<int, int> > InitMipsRating();
|
||||
|
||||
bool IsVersionCompatible(int target_version, int package_version);
|
||||
int GetHardwareRating(int platform, int cpu_id, const std::vector<std::pair<int, int> >& group);
|
||||
|
@ -111,7 +111,6 @@ TEST(Split, SplitMultiElementString)
|
||||
TEST(CpuCount, CheckNonZero)
|
||||
{
|
||||
EXPECT_TRUE(GetProcessorCount() != 0);
|
||||
EXPECT_TRUE(a.find("") == a.end());
|
||||
}
|
||||
|
||||
TEST(GetCpuInfo, GetCpuInfo)
|
||||
@ -127,7 +126,7 @@ TEST(CpuID, CheckNotEmpy)
|
||||
EXPECT_NE(0, cpu_id);
|
||||
}
|
||||
|
||||
#ifdef __i386__
|
||||
#if defined(__i386__)
|
||||
TEST(CpuID, CheckX86)
|
||||
{
|
||||
int cpu_id = GetCpuID();
|
||||
@ -139,14 +138,14 @@ TEST(CpuID, CheckSSE2)
|
||||
int cpu_id = GetCpuID();
|
||||
EXPECT_TRUE(cpu_id & FEATURES_HAS_SSE2);
|
||||
}
|
||||
#elseif __mips
|
||||
#ifdef __SUPPORT_MIPS
|
||||
TEST(CpuID, CheckMips)
|
||||
{
|
||||
#elif defined(__mips)
|
||||
#ifdef __SUPPORT_MIPS
|
||||
TEST(CpuID, CheckMips)
|
||||
{
|
||||
int cpu_id = GetCpuID();
|
||||
EXPECT_TRUE(cpu_id & ARCH_MIPS);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
TEST(TegraDetector, Detect)
|
||||
{
|
||||
@ -175,4 +174,4 @@ TEST(PlatfromDetector, CheckTegra)
|
||||
{
|
||||
EXPECT_NE(PLATFORM_UNKNOWN, DetectKnownPlatforms());
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
@ -69,7 +69,7 @@ TEST(OpenCVEngineTest, GetPathForExecHWExistVersion)
|
||||
{
|
||||
sp<IOpenCVEngine> Engine = InitConnect();
|
||||
Starter.PackageManager->InstalledPackages.clear();
|
||||
Starter.PackageManager->InstallVersion("240", PLATFORM_UNKNOWN, ARCH_X86);
|
||||
Starter.PackageManager->InstallVersion(2040000, PLATFORM_UNKNOWN, ARCH_X86);
|
||||
EXPECT_FALSE(NULL == Engine.get());
|
||||
String16 result = Engine->GetLibPathByVersion(String16("2.4"));
|
||||
EXPECT_STREQ("/data/data/org.opencv.lib_v24_x86/lib", String8(result).string());
|
||||
@ -79,7 +79,7 @@ TEST(OpenCVEngineTest, GetPathForExecHWOldVersion)
|
||||
{
|
||||
sp<IOpenCVEngine> Engine = InitConnect();
|
||||
Starter.PackageManager->InstalledPackages.clear();
|
||||
Starter.PackageManager->InstallVersion("242", PLATFORM_UNKNOWN, ARCH_X86);
|
||||
Starter.PackageManager->InstallVersion(2040200, PLATFORM_UNKNOWN, ARCH_X86);
|
||||
EXPECT_FALSE(NULL == Engine.get());
|
||||
String16 result = Engine->GetLibPathByVersion(String16("2.4.1"));
|
||||
EXPECT_STREQ("/data/data/org.opencv.lib_v24_x86/lib", String8(result).string());
|
||||
@ -89,7 +89,7 @@ TEST(OpenCVEngineTest, GetPathForExecHWNewVersion)
|
||||
{
|
||||
sp<IOpenCVEngine> Engine = InitConnect();
|
||||
Starter.PackageManager->InstalledPackages.clear();
|
||||
Starter.PackageManager->InstallVersion("241", PLATFORM_UNKNOWN, ARCH_X86);
|
||||
Starter.PackageManager->InstallVersion(2040100, PLATFORM_UNKNOWN, ARCH_X86);
|
||||
EXPECT_FALSE(NULL == Engine.get());
|
||||
String16 result = Engine->GetLibPathByVersion(String16("2.4.2"));
|
||||
EXPECT_EQ(0, result.size());
|
||||
@ -100,7 +100,7 @@ TEST(OpenCVEngineTest, GetPathForExecHWExistVersion)
|
||||
{
|
||||
sp<IOpenCVEngine> Engine = InitConnect();
|
||||
Starter.PackageManager->InstalledPackages.clear();
|
||||
Starter.PackageManager->InstallVersion("240", PLATFORM_UNKNOWN, ARCH_MIPS);
|
||||
Starter.PackageManager->InstallVersion(2040000, PLATFORM_UNKNOWN, ARCH_MIPS);
|
||||
EXPECT_FALSE(NULL == Engine.get());
|
||||
String16 result = Engine->GetLibPathByVersion(String16("2.4"));
|
||||
EXPECT_STREQ("/data/data/org.opencv.lib_v24_mips/lib", String8(result).string());
|
||||
@ -110,7 +110,7 @@ TEST(OpenCVEngineTest, GetPathForExecHWOldVersion)
|
||||
{
|
||||
sp<IOpenCVEngine> Engine = InitConnect();
|
||||
Starter.PackageManager->InstalledPackages.clear();
|
||||
Starter.PackageManager->InstallVersion("242", PLATFORM_UNKNOWN, ARCH_MIPS);
|
||||
Starter.PackageManager->InstallVersion(2040200, PLATFORM_UNKNOWN, ARCH_MIPS);
|
||||
EXPECT_FALSE(NULL == Engine.get());
|
||||
String16 result = Engine->GetLibPathByVersion(String16("2.4.1"));
|
||||
EXPECT_STREQ("/data/data/org.opencv.lib_v24_mips/lib", String8(result).string());
|
||||
@ -120,7 +120,7 @@ TEST(OpenCVEngineTest, GetPathForExecHWNewVersion)
|
||||
{
|
||||
sp<IOpenCVEngine> Engine = InitConnect();
|
||||
Starter.PackageManager->InstalledPackages.clear();
|
||||
Starter.PackageManager->InstallVersion("241", PLATFORM_UNKNOWN, ARCH_MIPS);
|
||||
Starter.PackageManager->InstallVersion(2040100, PLATFORM_UNKNOWN, ARCH_MIPS);
|
||||
EXPECT_FALSE(NULL == Engine.get());
|
||||
String16 result = Engine->GetLibPathByVersion(String16("2.4.2"));
|
||||
EXPECT_EQ(0, result.size());
|
||||
@ -131,7 +131,7 @@ TEST(OpenCVEngineTest, GetPathForExecHWExistVersion)
|
||||
{
|
||||
sp<IOpenCVEngine> Engine = InitConnect();
|
||||
Starter.PackageManager->InstalledPackages.clear();
|
||||
Starter.PackageManager->InstallVersion("240", PLATFORM_TEGRA3, ARCH_ARMv7 | FEATURES_HAS_NEON);
|
||||
Starter.PackageManager->InstallVersion(2040000, PLATFORM_TEGRA3, ARCH_ARMv7 | FEATURES_HAS_VFPv3 | FEATURES_HAS_NEON);
|
||||
EXPECT_FALSE(NULL == Engine.get());
|
||||
String16 result = Engine->GetLibPathByVersion(String16("2.4"));
|
||||
#ifdef __SUPPORT_TEGRA3
|
||||
@ -149,7 +149,7 @@ TEST(OpenCVEngineTest, GetPathForExecHWOldVersion)
|
||||
{
|
||||
sp<IOpenCVEngine> Engine = InitConnect();
|
||||
Starter.PackageManager->InstalledPackages.clear();
|
||||
Starter.PackageManager->InstallVersion("242", PLATFORM_TEGRA3, ARCH_ARMv7 | FEATURES_HAS_NEON);
|
||||
Starter.PackageManager->InstallVersion(2040200, PLATFORM_TEGRA3, ARCH_ARMv7 | FEATURES_HAS_VFPv3 | FEATURES_HAS_NEON);
|
||||
EXPECT_FALSE(NULL == Engine.get());
|
||||
String16 result = Engine->GetLibPathByVersion(String16("2.4.1"));
|
||||
#ifdef __SUPPORT_TEGRA3
|
||||
@ -167,7 +167,7 @@ TEST(OpenCVEngineTest, GetPathForExecHWNewVersion)
|
||||
{
|
||||
sp<IOpenCVEngine> Engine = InitConnect();
|
||||
Starter.PackageManager->InstalledPackages.clear();
|
||||
Starter.PackageManager->InstallVersion("241", PLATFORM_TEGRA3, ARCH_ARMv7 | FEATURES_HAS_NEON);
|
||||
Starter.PackageManager->InstallVersion(2040100, PLATFORM_TEGRA3, ARCH_ARMv7 | FEATURES_HAS_NEON);
|
||||
EXPECT_FALSE(NULL == Engine.get());
|
||||
String16 result = Engine->GetLibPathByVersion(String16("2.4.2"));
|
||||
EXPECT_EQ(0, result.size());
|
||||
@ -177,7 +177,7 @@ TEST(OpenCVEngineTest, GetPathForCompatiblePackage1)
|
||||
{
|
||||
sp<IOpenCVEngine> Engine = InitConnect();
|
||||
Starter.PackageManager->InstalledPackages.clear();
|
||||
Starter.PackageManager->InstallVersion("242", PLATFORM_UNKNOWN, ARCH_ARMv5);
|
||||
Starter.PackageManager->InstallVersion(2040200, PLATFORM_UNKNOWN, ARCH_ARMv5);
|
||||
EXPECT_FALSE(NULL == Engine.get());
|
||||
String16 result = Engine->GetLibPathByVersion(String16("2.4"));
|
||||
EXPECT_STREQ("/data/data/org.opencv.lib_v24_armv5/lib", String8(result).string());
|
||||
@ -187,7 +187,7 @@ TEST(OpenCVEngineTest, GetPathForCompatiblePackage2)
|
||||
{
|
||||
sp<IOpenCVEngine> Engine = InitConnect();
|
||||
Starter.PackageManager->InstalledPackages.clear();
|
||||
Starter.PackageManager->InstallVersion("242", PLATFORM_TEGRA3, ARCH_ARMv7 | FEATURES_HAS_NEON);
|
||||
Starter.PackageManager->InstallVersion(2040200, PLATFORM_TEGRA3, ARCH_ARMv7 | FEATURES_HAS_VFPv3 | FEATURES_HAS_NEON);
|
||||
EXPECT_FALSE(NULL == Engine.get());
|
||||
String16 result = Engine->GetLibPathByVersion(String16("2.4"));
|
||||
#ifdef __SUPPORT_TEGRA3
|
||||
@ -225,7 +225,7 @@ TEST(OpenCVEngineTest, GetPathForInCompatiblePackage1)
|
||||
{
|
||||
sp<IOpenCVEngine> Engine = InitConnect();
|
||||
Starter.PackageManager->InstalledPackages.clear();
|
||||
Starter.PackageManager->InstallVersion("242", PLATFORM_UNKNOWN, ARCH_X64);
|
||||
Starter.PackageManager->InstallVersion(2040200, PLATFORM_UNKNOWN, ARCH_X64);
|
||||
EXPECT_FALSE(NULL == Engine.get());
|
||||
String16 result = Engine->GetLibPathByVersion(String16("2.4"));
|
||||
EXPECT_EQ(0, result.size());
|
||||
@ -235,7 +235,7 @@ TEST(OpenCVEngineTest, GetPathForInCompatiblePackage1)
|
||||
{
|
||||
sp<IOpenCVEngine> Engine = InitConnect();
|
||||
Starter.PackageManager->InstalledPackages.clear();
|
||||
Starter.PackageManager->InstallVersion("242", PLATFORM_UNKNOWN, ARCH_ARMv7);
|
||||
Starter.PackageManager->InstallVersion(2040200, PLATFORM_UNKNOWN, ARCH_ARMv7);
|
||||
EXPECT_FALSE(NULL == Engine.get());
|
||||
String16 result = Engine->GetLibPathByVersion(String16("2.4"));
|
||||
EXPECT_EQ(0, result.size());
|
||||
@ -248,4 +248,4 @@ TEST(OpenCVEngineTest, GetPathForUnExistVersion)
|
||||
EXPECT_FALSE(NULL == Engine.get());
|
||||
String16 result = Engine->GetLibPathByVersion(String16("2.5"));
|
||||
EXPECT_EQ(0, result.size());
|
||||
}
|
||||
}
|
||||
|
@ -11,14 +11,14 @@ using namespace std;
|
||||
|
||||
TEST(PackageInfo, FullNameArmv7)
|
||||
{
|
||||
PackageInfo info("230", PLATFORM_UNKNOWN, ARCH_ARMv7);
|
||||
PackageInfo info(2030000, PLATFORM_UNKNOWN, ARCH_ARMv7);
|
||||
string name = info.GetFullName();
|
||||
EXPECT_STREQ("org.opencv.lib_v23_armv7a", name.c_str());
|
||||
}
|
||||
|
||||
TEST(PackageInfo, FullNameArmv7Neon)
|
||||
{
|
||||
PackageInfo info("241", PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_NEON);
|
||||
PackageInfo info(2040100, PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_NEON);
|
||||
string name = info.GetFullName();
|
||||
#ifdef __SUPPORT_ARMEABI_V7A_FEATURES
|
||||
EXPECT_STREQ("org.opencv.lib_v24_armv7a_neon", name.c_str());
|
||||
@ -29,14 +29,14 @@ TEST(PackageInfo, FullNameArmv7Neon)
|
||||
|
||||
TEST(PackageInfo, FullNameArmv7VFPv3)
|
||||
{
|
||||
PackageInfo info("233", PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_VFPv3);
|
||||
PackageInfo info(2030300, PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_VFPv3);
|
||||
string name = info.GetFullName();
|
||||
EXPECT_STREQ("org.opencv.lib_v23_armv7a", name.c_str());
|
||||
}
|
||||
|
||||
TEST(PackageInfo, FullNameArmv7VFPv3Neon)
|
||||
{
|
||||
PackageInfo info("230", PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_VFPv3 | FEATURES_HAS_NEON);
|
||||
PackageInfo info(2030000, PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_VFPv3 | FEATURES_HAS_NEON);
|
||||
string name = info.GetFullName();
|
||||
#ifdef __SUPPORT_ARMEABI_V7A_FEATURES
|
||||
EXPECT_STREQ("org.opencv.lib_v23_armv7a_neon", name.c_str());
|
||||
@ -47,21 +47,21 @@ TEST(PackageInfo, FullNameArmv7VFPv3Neon)
|
||||
|
||||
TEST(PackageInfo, FullNameArmv5)
|
||||
{
|
||||
PackageInfo info("230", PLATFORM_UNKNOWN, ARCH_ARMv5);
|
||||
PackageInfo info(2030000, PLATFORM_UNKNOWN, ARCH_ARMv5);
|
||||
string name = info.GetFullName();
|
||||
EXPECT_STREQ("org.opencv.lib_v23_armv5", name.c_str());
|
||||
}
|
||||
|
||||
TEST(PackageInfo, FullNameArmv6)
|
||||
{
|
||||
PackageInfo info("230", PLATFORM_UNKNOWN, ARCH_ARMv6);
|
||||
PackageInfo info(2030000, PLATFORM_UNKNOWN, ARCH_ARMv6);
|
||||
string name = info.GetFullName();
|
||||
EXPECT_STREQ("org.opencv.lib_v23_armv5", name.c_str());
|
||||
}
|
||||
|
||||
TEST(PackageInfo, FullNameArmv6VFPv3)
|
||||
{
|
||||
PackageInfo info("232", PLATFORM_UNKNOWN, ARCH_ARMv6 | FEATURES_HAS_VFPv3);
|
||||
PackageInfo info(2030200, PLATFORM_UNKNOWN, ARCH_ARMv6 | FEATURES_HAS_VFPv3);
|
||||
string name = info.GetFullName();
|
||||
#ifdef __SUPPORT_ARMEABI_FEATURES
|
||||
EXPECT_STREQ("org.opencv.lib_v23_armv5_vfpv3", name.c_str());
|
||||
@ -72,7 +72,7 @@ TEST(PackageInfo, FullNameArmv6VFPv3)
|
||||
|
||||
TEST(PackageInfo, FullNameTegra3)
|
||||
{
|
||||
PackageInfo info("230", PLATFORM_TEGRA3, ARCH_ARMv7 | FEATURES_HAS_NEON);
|
||||
PackageInfo info(2030000, PLATFORM_TEGRA3, ARCH_ARMv7 | FEATURES_HAS_NEON);
|
||||
string name = info.GetFullName();
|
||||
#ifdef __SUPPORT_TEGRA3
|
||||
EXPECT_STREQ("org.opencv.lib_v23_tegra3", name.c_str());
|
||||
@ -87,7 +87,7 @@ TEST(PackageInfo, FullNameTegra3)
|
||||
|
||||
TEST(PackageInfo, FullNameX86SSE2)
|
||||
{
|
||||
PackageInfo info("230", PLATFORM_UNKNOWN, ARCH_X86 | FEATURES_HAS_SSE2);
|
||||
PackageInfo info(2030000, PLATFORM_UNKNOWN, ARCH_X86 | FEATURES_HAS_SSE2);
|
||||
string name = info.GetFullName();
|
||||
#ifdef __SUPPORT_INTEL_FEATURES
|
||||
EXPECT_STREQ("org.opencv.lib_v23_x86_sse2", name.c_str());
|
||||
@ -99,7 +99,7 @@ TEST(PackageInfo, FullNameX86SSE2)
|
||||
#ifdef __SUPPORT_MIPS
|
||||
TEST(PackageInfo, FullNameMips)
|
||||
{
|
||||
PackageInfo info("243", PLATFORM_UNKNOWN, ARCH_MIPS);
|
||||
PackageInfo info(2040300, PLATFORM_UNKNOWN, ARCH_MIPS);
|
||||
string name = info.GetFullName();
|
||||
EXPECT_STREQ("org.opencv.lib_v24_mips", name.c_str());
|
||||
}
|
||||
@ -108,21 +108,21 @@ TEST(PackageInfo, FullNameMips)
|
||||
TEST(PackageInfo, Armv7NeonFromFullName)
|
||||
{
|
||||
PackageInfo info("org.opencv.lib_v23_armv7a_neon", "/data/data/org.opencv.lib_v23_armv7_neon");
|
||||
EXPECT_EQ("230", info.GetVersion());
|
||||
EXPECT_EQ(2030000, info.GetVersion());
|
||||
EXPECT_EQ(ARCH_ARMv7 | FEATURES_HAS_NEON, info.GetCpuID());
|
||||
}
|
||||
|
||||
TEST(PackageInfo, Armv5FromFullName)
|
||||
{
|
||||
PackageInfo info("org.opencv.lib_v23_armv5", "/data/data/org.opencv.lib_v23_armv5");
|
||||
EXPECT_EQ("230", info.GetVersion());
|
||||
EXPECT_EQ(2030000, info.GetVersion());
|
||||
EXPECT_EQ(ARCH_ARMv5, info.GetCpuID());
|
||||
}
|
||||
|
||||
TEST(PackageInfo, Armv5VFPv3FromFullName)
|
||||
{
|
||||
PackageInfo info("org.opencv.lib_v23_armv5_vfpv3", "/data/data/org.opencv.lib_v23_armv5_vfpv3");
|
||||
EXPECT_EQ("230", info.GetVersion());
|
||||
EXPECT_EQ(2030000, info.GetVersion());
|
||||
EXPECT_EQ(ARCH_ARMv5 | FEATURES_HAS_VFPv3, info.GetCpuID());
|
||||
}
|
||||
|
||||
@ -131,20 +131,20 @@ TEST(PackageInfo, X86SSE2FromFullName)
|
||||
PackageInfo info("org.opencv.lib_v24_x86_sse2", "/data/data/org.opencv.lib_v24_x86_sse2");
|
||||
EXPECT_EQ(PLATFORM_UNKNOWN, info.GetPlatform());
|
||||
EXPECT_EQ(ARCH_X86 | FEATURES_HAS_SSE2, info.GetCpuID());
|
||||
EXPECT_EQ("240", info.GetVersion());
|
||||
EXPECT_EQ(2040000, info.GetVersion());
|
||||
}
|
||||
|
||||
TEST(PackageInfo, Tegra2FromFullName)
|
||||
{
|
||||
PackageInfo info("org.opencv.lib_v23_tegra2", "/data/data/org.opencv.lib_v23_tegra2");
|
||||
EXPECT_EQ("230", info.GetVersion());
|
||||
EXPECT_EQ(2030000, info.GetVersion());
|
||||
EXPECT_EQ(PLATFORM_TEGRA2, info.GetPlatform());
|
||||
}
|
||||
|
||||
TEST(PackageInfo, Tegra3FromFullName)
|
||||
{
|
||||
PackageInfo info("org.opencv.lib_v24_tegra3", "/data/data/org.opencv.lib_v24_tegra3");
|
||||
EXPECT_EQ("240", info.GetVersion());
|
||||
EXPECT_EQ(2040000, info.GetVersion());
|
||||
EXPECT_EQ(PLATFORM_TEGRA3, info.GetPlatform());
|
||||
}
|
||||
|
||||
@ -152,14 +152,14 @@ TEST(PackageInfo, Tegra3FromFullName)
|
||||
TEST(PackageInfo, MipsFromFullName)
|
||||
{
|
||||
PackageInfo info("org.opencv.lib_v24_mips", "/data/data/org.opencv.lib_v24_mips");
|
||||
EXPECT_EQ("240", info.GetVersion());
|
||||
EXPECT_EQ(2040000, info.GetVersion());
|
||||
EXPECT_EQ(ARCH_MIPS, info.GetCpuID());
|
||||
}
|
||||
#endif
|
||||
|
||||
TEST(PackageInfo, Comparator1)
|
||||
{
|
||||
PackageInfo info1("240", PLATFORM_UNKNOWN, ARCH_X86);
|
||||
PackageInfo info1(2040000, PLATFORM_UNKNOWN, ARCH_X86);
|
||||
PackageInfo info2("org.opencv.lib_v24_x86", "/data/data/org.opencv.lib_v24_x86");
|
||||
EXPECT_STREQ(info1.GetFullName().c_str(), info2.GetFullName().c_str());
|
||||
EXPECT_EQ(info1, info2);
|
||||
@ -167,7 +167,7 @@ TEST(PackageInfo, Comparator1)
|
||||
|
||||
TEST(PackageInfo, Comparator2)
|
||||
{
|
||||
PackageInfo info1("240", PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_NEON | FEATURES_HAS_VFPv3);
|
||||
PackageInfo info1(2040000, PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_NEON | FEATURES_HAS_VFPv3);
|
||||
#ifdef __SUPPORT_ARMEABI_V7A_FEATURES
|
||||
PackageInfo info2("org.opencv.lib_v24_armv7a_neon", "/data/data/org.opencv.lib_v24_armv7a_neon");
|
||||
#else
|
||||
@ -180,7 +180,7 @@ TEST(PackageInfo, Comparator2)
|
||||
#ifdef __SUPPORT_TEGRA3
|
||||
TEST(PackageInfo, Comparator3)
|
||||
{
|
||||
PackageInfo info1("230", PLATFORM_TEGRA3, 0);
|
||||
PackageInfo info1(2030000, PLATFORM_TEGRA3, 0);
|
||||
PackageInfo info2("org.opencv.lib_v23_tegra3", "/data/data/org.opencv.lib_v23_tegra3");
|
||||
EXPECT_STREQ(info1.GetFullName().c_str(), info2.GetFullName().c_str());
|
||||
EXPECT_EQ(info1, info2);
|
||||
|
@ -5,7 +5,6 @@
|
||||
#include "IOpenCVEngine.h"
|
||||
#include <utils/String16.h>
|
||||
#include <gtest/gtest.h>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@ -14,52 +13,52 @@ using namespace std;
|
||||
TEST(PackageManager, InstalledVersions)
|
||||
{
|
||||
PackageManagerStub pm;
|
||||
PackageInfo info("230", PLATFORM_UNKNOWN, ARCH_ARMv7);
|
||||
PackageInfo info(2030000, PLATFORM_UNKNOWN, ARCH_ARMv7);
|
||||
pm.InstalledPackages.push_back(info);
|
||||
std::set<string> versions = pm.GetInstalledVersions();
|
||||
std::vector<int> versions = pm.GetInstalledVersions();
|
||||
EXPECT_EQ(1, versions.size());
|
||||
EXPECT_EQ("230", *versions.begin());
|
||||
EXPECT_EQ(2030000, *versions.begin());
|
||||
}
|
||||
|
||||
TEST(PackageManager, CheckVersionInstalled)
|
||||
{
|
||||
PackageManagerStub pm;
|
||||
PackageInfo info("230", PLATFORM_UNKNOWN, ARCH_ARMv7);
|
||||
PackageInfo info(2030000, PLATFORM_UNKNOWN, ARCH_ARMv7);
|
||||
pm.InstalledPackages.push_back(info);
|
||||
EXPECT_TRUE(pm.CheckVersionInstalled("230", PLATFORM_UNKNOWN, ARCH_ARMv7));
|
||||
EXPECT_TRUE(pm.CheckVersionInstalled(2030000, PLATFORM_UNKNOWN, ARCH_ARMv7));
|
||||
}
|
||||
|
||||
TEST(PackageManager, InstallVersion)
|
||||
{
|
||||
PackageManagerStub pm;
|
||||
PackageInfo info("230", PLATFORM_UNKNOWN, ARCH_ARMv5);
|
||||
PackageInfo info(2030000, PLATFORM_UNKNOWN, ARCH_ARMv5);
|
||||
pm.InstalledPackages.push_back(info);
|
||||
EXPECT_TRUE(pm.InstallVersion("240", PLATFORM_UNKNOWN, ARCH_ARMv5));
|
||||
EXPECT_TRUE(pm.InstallVersion(2040000, PLATFORM_UNKNOWN, ARCH_ARMv5));
|
||||
EXPECT_EQ(2, pm.InstalledPackages.size());
|
||||
EXPECT_TRUE(pm.CheckVersionInstalled("240", PLATFORM_UNKNOWN, ARCH_ARMv5));
|
||||
EXPECT_TRUE(pm.CheckVersionInstalled(2040000, PLATFORM_UNKNOWN, ARCH_ARMv5));
|
||||
}
|
||||
|
||||
TEST(PackageManager, GetPackagePathForArmv5)
|
||||
{
|
||||
PackageManagerStub pm;
|
||||
EXPECT_TRUE(pm.InstallVersion("243", PLATFORM_UNKNOWN, ARCH_ARMv5));
|
||||
string path = pm.GetPackagePathByVersion("243", PLATFORM_UNKNOWN, ARCH_ARMv5);
|
||||
EXPECT_TRUE(pm.InstallVersion(2040300, PLATFORM_UNKNOWN, ARCH_ARMv5));
|
||||
string path = pm.GetPackagePathByVersion(2040300, PLATFORM_UNKNOWN, ARCH_ARMv5);
|
||||
EXPECT_STREQ("/data/data/org.opencv.lib_v24_armv5/lib", path.c_str());
|
||||
}
|
||||
|
||||
TEST(PackageManager, GetPackagePathForArmv7)
|
||||
{
|
||||
PackageManagerStub pm;
|
||||
EXPECT_TRUE(pm.InstallVersion("230", PLATFORM_UNKNOWN, ARCH_ARMv7));
|
||||
string path = pm.GetPackagePathByVersion("230", PLATFORM_UNKNOWN, ARCH_ARMv7);
|
||||
EXPECT_TRUE(pm.InstallVersion(2030000, PLATFORM_UNKNOWN, ARCH_ARMv7));
|
||||
string path = pm.GetPackagePathByVersion(2030000, PLATFORM_UNKNOWN, ARCH_ARMv7);
|
||||
EXPECT_STREQ("/data/data/org.opencv.lib_v23_armv7a/lib", path.c_str());
|
||||
}
|
||||
|
||||
TEST(PackageManager, GetPackagePathForArmv7Neon)
|
||||
{
|
||||
PackageManagerStub pm;
|
||||
EXPECT_TRUE(pm.InstallVersion("230", PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_NEON));
|
||||
string path = pm.GetPackagePathByVersion("230", PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_NEON);
|
||||
EXPECT_TRUE(pm.InstallVersion(2030000, PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_NEON));
|
||||
string path = pm.GetPackagePathByVersion(2030000, PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_NEON);
|
||||
#ifdef __SUPPORT_ARMEABI_V7A_FEATURES
|
||||
EXPECT_STREQ("/data/data/org.opencv.lib_v23_armv7a_neon/lib", path.c_str());
|
||||
#else
|
||||
@ -70,16 +69,16 @@ TEST(PackageManager, GetPackagePathForArmv7Neon)
|
||||
TEST(PackageManager, GetPackagePathForX86)
|
||||
{
|
||||
PackageManagerStub pm;
|
||||
EXPECT_TRUE(pm.InstallVersion("230", PLATFORM_UNKNOWN, ARCH_X86));
|
||||
string path = pm.GetPackagePathByVersion("230", PLATFORM_UNKNOWN, ARCH_X86);
|
||||
EXPECT_TRUE(pm.InstallVersion(2030000, PLATFORM_UNKNOWN, ARCH_X86));
|
||||
string path = pm.GetPackagePathByVersion(2030000, PLATFORM_UNKNOWN, ARCH_X86);
|
||||
EXPECT_STREQ("/data/data/org.opencv.lib_v23_x86/lib", path.c_str());
|
||||
}
|
||||
|
||||
TEST(PackageManager, GetPackagePathForX86SSE2)
|
||||
{
|
||||
PackageManagerStub pm;
|
||||
EXPECT_TRUE(pm.InstallVersion("230", PLATFORM_UNKNOWN, ARCH_X86 | FEATURES_HAS_SSE2));
|
||||
string path = pm.GetPackagePathByVersion("230", PLATFORM_UNKNOWN, ARCH_X86 | FEATURES_HAS_SSE2);
|
||||
EXPECT_TRUE(pm.InstallVersion(2030000, PLATFORM_UNKNOWN, ARCH_X86 | FEATURES_HAS_SSE2));
|
||||
string path = pm.GetPackagePathByVersion(2030000, PLATFORM_UNKNOWN, ARCH_X86 | FEATURES_HAS_SSE2);
|
||||
#ifdef __SUPPORT_INTEL_FEATURES
|
||||
EXPECT_STREQ("/data/data/org.opencv.lib_v23_x86_sse2/lib", path.c_str());
|
||||
#else
|
||||
@ -90,8 +89,8 @@ TEST(PackageManager, GetPackagePathForX86SSE2)
|
||||
TEST(PackageManager, GetPackagePathForTegra3)
|
||||
{
|
||||
PackageManagerStub pm;
|
||||
EXPECT_TRUE(pm.InstallVersion("230", PLATFORM_TEGRA3, ARCH_ARMv7 | FEATURES_HAS_NEON));
|
||||
string path = pm.GetPackagePathByVersion("230", PLATFORM_TEGRA3, ARCH_ARMv7 | FEATURES_HAS_NEON);
|
||||
EXPECT_TRUE(pm.InstallVersion(2030000, PLATFORM_TEGRA3, ARCH_ARMv7 | FEATURES_HAS_VFPv3 | FEATURES_HAS_NEON));
|
||||
string path = pm.GetPackagePathByVersion(2030000, PLATFORM_TEGRA3, ARCH_ARMv7 | FEATURES_HAS_VFPv3 | FEATURES_HAS_NEON);
|
||||
#ifdef __SUPPORT_TEGRA3
|
||||
EXPECT_STREQ("/data/data/org.opencv.lib_v23_tegra3/lib", path.c_str());
|
||||
#else
|
||||
@ -107,8 +106,8 @@ TEST(PackageManager, GetPackagePathForTegra3)
|
||||
TEST(PackageManager, GetPackagePathForMips)
|
||||
{
|
||||
PackageManagerStub pm;
|
||||
EXPECT_TRUE(pm.InstallVersion("243", PLATFORM_UNKNOWN, ARCH_MIPS));
|
||||
string path = pm.GetPackagePathByVersion("243", PLATFORM_UNKNOWN, ARCH_MIPS);
|
||||
EXPECT_TRUE(pm.InstallVersion(2040000, PLATFORM_UNKNOWN, ARCH_MIPS));
|
||||
string path = pm.GetPackagePathByVersion(2040000, PLATFORM_UNKNOWN, ARCH_MIPS);
|
||||
EXPECT_STREQ("/data/data/org.opencv.lib_v24_mips/lib", path.c_str());
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user