aboutsummaryrefslogtreecommitdiff
path: root/tests/src/com/android/tradefed/result/ATestFileSystemLogSaverTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'tests/src/com/android/tradefed/result/ATestFileSystemLogSaverTest.java')
-rw-r--r--tests/src/com/android/tradefed/result/ATestFileSystemLogSaverTest.java67
1 files changed, 67 insertions, 0 deletions
diff --git a/tests/src/com/android/tradefed/result/ATestFileSystemLogSaverTest.java b/tests/src/com/android/tradefed/result/ATestFileSystemLogSaverTest.java
new file mode 100644
index 000000000..63de554f0
--- /dev/null
+++ b/tests/src/com/android/tradefed/result/ATestFileSystemLogSaverTest.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.tradefed.result;
+
+import static org.junit.Assert.*;
+
+import com.android.tradefed.build.IBuildInfo;
+import com.android.tradefed.config.ConfigurationException;
+import com.android.tradefed.config.OptionSetter;
+import com.android.tradefed.invoker.InvocationContext;
+import com.android.tradefed.util.FileUtil;
+
+import java.io.File;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+import org.mockito.Mockito;
+
+/** Unit tests for {@link ATestFileSystemLogSaver}. */
+@RunWith(JUnit4.class)
+public class ATestFileSystemLogSaverTest {
+
+ private File mReportDir;
+ private IBuildInfo mMockBuild;
+ private InvocationContext mContext;
+
+ @Before
+ public void setUp() throws Exception {
+ mReportDir = FileUtil.createTempDir("tmpdir");
+ mMockBuild = Mockito.mock(IBuildInfo.class);
+ mContext = new InvocationContext();
+ mContext.addDeviceBuildInfo("fakeDevice", mMockBuild);
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ FileUtil.recursiveDelete(mReportDir);
+ }
+
+ /** Test if generated dir in specific path. */
+ @Test
+ public void testGenerateLogReportDir() throws ConfigurationException {
+ ATestFileSystemLogSaver saver = new ATestFileSystemLogSaver();
+ OptionSetter setter = new OptionSetter(saver);
+ setter.setOptionValue("atest-log-file-path", mReportDir.getAbsolutePath());
+ saver.invocationStarted(mContext);
+ File generatedDir = new File(saver.getLogReportDir().getPath());
+ File expectedParentFolder = generatedDir.getParentFile();
+ assertEquals(expectedParentFolder.getAbsolutePath(), mReportDir.getAbsolutePath());
+ }
+}