Home | History | Annotate | Download | only in mini_installer
      1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #include <windows.h>
      6 
      7 #include "base/files/file_path.h"
      8 #include "base/files/scoped_temp_dir.h"
      9 #include "base/path_service.h"
     10 #include "chrome/installer/mini_installer/decompress.h"
     11 #include "testing/gtest/include/gtest/gtest.h"
     12 
     13 TEST(MiniDecompressTest, ExpandTest) {
     14   base::FilePath source_path;
     15   PathService::Get(base::DIR_SOURCE_ROOT, &source_path);
     16   source_path = source_path.Append(FILE_PATH_LITERAL("chrome"))
     17       .Append(FILE_PATH_LITERAL("installer"))
     18       .Append(FILE_PATH_LITERAL("test"))
     19       .Append(FILE_PATH_LITERAL("data"))
     20       .Append(FILE_PATH_LITERAL("SETUP.EX_"));
     21 
     22   // Prepare a temp folder that will be automatically deleted along with
     23   // our temporary test data.
     24   base::ScopedTempDir temp_dir;
     25   EXPECT_TRUE(temp_dir.CreateUniqueTempDir());
     26   base::FilePath dest_path(
     27       temp_dir.path().Append(FILE_PATH_LITERAL("setup.exe")));
     28 
     29   // Decompress our test file.
     30   EXPECT_TRUE(mini_installer::Expand(source_path.value().c_str(),
     31                                      dest_path.value().c_str()));
     32 
     33   // Check if the expanded file is a valid executable.
     34   DWORD type = static_cast<DWORD>(-1);
     35   EXPECT_TRUE(GetBinaryType(dest_path.value().c_str(), &type));
     36   EXPECT_EQ(SCS_32BIT_BINARY, type);
     37 }
     38