Break away from longer file extensions.
Missing "break" statements were causing us to match invalid file
extensions like "fpe."
Bug: 116751711
Test: /data/nativetest64/installd_utils_test/installd_utils_test
Change-Id: I250e9f16df998d50f5aaefb0d3a0f68fd5f73835
diff --git a/cmds/installd/tests/installd_utils_test.cpp b/cmds/installd/tests/installd_utils_test.cpp
index bcdd03e..ad7a5ae 100644
--- a/cmds/installd/tests/installd_utils_test.cpp
+++ b/cmds/installd/tests/installd_utils_test.cpp
@@ -21,6 +21,7 @@
#include <gtest/gtest.h>
#include "InstalldNativeService.h"
+#include "MatchExtensionGen.h"
#include "globals.h"
#include "utils.h"
@@ -529,5 +530,19 @@
EXPECT_NE(0, validate_apk_path_subdirs("/data/app/com.example/dir/dir/dir//file"));
}
+TEST_F(UtilsTest, MatchExtension_Valid) {
+ EXPECT_EQ(AID_MEDIA_VIDEO, MatchExtension("mpg"));
+ EXPECT_EQ(AID_MEDIA_VIDEO, MatchExtension("mpeg"));
+ EXPECT_EQ(AID_MEDIA_VIDEO, MatchExtension("mPeG"));
+ EXPECT_EQ(AID_MEDIA_VIDEO, MatchExtension("MPEG"));
+}
+
+TEST_F(UtilsTest, MatchExtension_Invalid) {
+ EXPECT_EQ(0, MatchExtension("log"));
+ EXPECT_EQ(0, MatchExtension("3amp"));
+ EXPECT_EQ(0, MatchExtension("fpe"));
+ EXPECT_EQ(0, MatchExtension("docx"));
+}
+
} // namespace installd
} // namespace android