| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // A test that exercises Chrome Frame's DLL Redirctor update code. This test | 5 // A test that exercises Chrome Frame's DLL Redirctor update code. This test |
| 6 // generates a new version of CF from the one already in the build folder and | 6 // generates a new version of CF from the one already in the build folder and |
| 7 // then loads them both into the current process to verify the handoff. | 7 // then loads them both into the current process to verify the handoff. |
| 8 | 8 |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/file_version_info.h" | 10 #include "base/file_version_info.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 public: | 32 public: |
| 33 // This sets up the following directory structure: | 33 // This sets up the following directory structure: |
| 34 // TEMP\<version X>\npchrome_frame.dll | 34 // TEMP\<version X>\npchrome_frame.dll |
| 35 // \<version X+1>\npchrome_frame.dll | 35 // \<version X+1>\npchrome_frame.dll |
| 36 // | 36 // |
| 37 // This structure emulates enough of the directory structure of a Chrome | 37 // This structure emulates enough of the directory structure of a Chrome |
| 38 // install to test upgrades. | 38 // install to test upgrades. |
| 39 static void SetUpTestCase() { | 39 static void SetUpTestCase() { |
| 40 // First ensure that we can find the built Chrome Frame DLL. | 40 // First ensure that we can find the built Chrome Frame DLL. |
| 41 base::FilePath build_chrome_frame_dll = GetChromeFrameBuildPath(); | 41 base::FilePath build_chrome_frame_dll = GetChromeFrameBuildPath(); |
| 42 ASSERT_TRUE(file_util::PathExists(build_chrome_frame_dll)); | 42 ASSERT_TRUE(base::PathExists(build_chrome_frame_dll)); |
| 43 | 43 |
| 44 // Then grab its version. | 44 // Then grab its version. |
| 45 scoped_ptr<FileVersionInfo> original_version_info( | 45 scoped_ptr<FileVersionInfo> original_version_info( |
| 46 FileVersionInfo::CreateFileVersionInfo(build_chrome_frame_dll)); | 46 FileVersionInfo::CreateFileVersionInfo(build_chrome_frame_dll)); |
| 47 ASSERT_TRUE(original_version_info != NULL); | 47 ASSERT_TRUE(original_version_info != NULL); |
| 48 original_version_.reset( | 48 original_version_.reset( |
| 49 new Version(WideToASCII(original_version_info->file_version()))); | 49 new Version(WideToASCII(original_version_info->file_version()))); |
| 50 ASSERT_TRUE(original_version_->IsValid()); | 50 ASSERT_TRUE(original_version_->IsValid()); |
| 51 | 51 |
| 52 // Make a place for us to run the test from. | 52 // Make a place for us to run the test from. |
| 53 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 53 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 54 | 54 |
| 55 // Make a versioned dir for the original chrome frame dll to run under. | 55 // Make a versioned dir for the original chrome frame dll to run under. |
| 56 base::FilePath original_version_dir( | 56 base::FilePath original_version_dir( |
| 57 temp_dir_.path().AppendASCII(original_version_->GetString())); | 57 temp_dir_.path().AppendASCII(original_version_->GetString())); |
| 58 ASSERT_TRUE(file_util::CreateDirectory(original_version_dir)); | 58 ASSERT_TRUE(file_util::CreateDirectory(original_version_dir)); |
| 59 | 59 |
| 60 // Now move the original DLL that we will operate on into a named-version | 60 // Now move the original DLL that we will operate on into a named-version |
| 61 // folder. | 61 // folder. |
| 62 original_chrome_frame_dll_ = | 62 original_chrome_frame_dll_ = |
| 63 original_version_dir.Append(build_chrome_frame_dll.BaseName()); | 63 original_version_dir.Append(build_chrome_frame_dll.BaseName()); |
| 64 ASSERT_TRUE(base::CopyFile(build_chrome_frame_dll, | 64 ASSERT_TRUE(base::CopyFile(build_chrome_frame_dll, |
| 65 original_chrome_frame_dll_)); | 65 original_chrome_frame_dll_)); |
| 66 ASSERT_TRUE(file_util::PathExists(original_chrome_frame_dll_)); | 66 ASSERT_TRUE(base::PathExists(original_chrome_frame_dll_)); |
| 67 | 67 |
| 68 // Temporary location for the new Chrome Frame DLL. | 68 // Temporary location for the new Chrome Frame DLL. |
| 69 base::FilePath temporary_new_chrome_frame_dll( | 69 base::FilePath temporary_new_chrome_frame_dll( |
| 70 temp_dir_.path().Append(build_chrome_frame_dll.BaseName())); | 70 temp_dir_.path().Append(build_chrome_frame_dll.BaseName())); |
| 71 | 71 |
| 72 // Generate the version-bumped Chrome Frame DLL to a temporary path. | 72 // Generate the version-bumped Chrome Frame DLL to a temporary path. |
| 73 ASSERT_TRUE( | 73 ASSERT_TRUE( |
| 74 upgrade_test::GenerateAlternatePEFileVersion( | 74 upgrade_test::GenerateAlternatePEFileVersion( |
| 75 original_chrome_frame_dll_, | 75 original_chrome_frame_dll_, |
| 76 temporary_new_chrome_frame_dll, | 76 temporary_new_chrome_frame_dll, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 88 ASSERT_EQ(new_version_->CompareTo(*original_version_.get()), 1); | 88 ASSERT_EQ(new_version_->CompareTo(*original_version_.get()), 1); |
| 89 | 89 |
| 90 // Now move the new Chrome Frame dll to its final resting place: | 90 // Now move the new Chrome Frame dll to its final resting place: |
| 91 base::FilePath new_version_dir( | 91 base::FilePath new_version_dir( |
| 92 temp_dir_.path().AppendASCII(new_version_->GetString())); | 92 temp_dir_.path().AppendASCII(new_version_->GetString())); |
| 93 ASSERT_TRUE(file_util::CreateDirectory(new_version_dir)); | 93 ASSERT_TRUE(file_util::CreateDirectory(new_version_dir)); |
| 94 new_chrome_frame_dll_ = | 94 new_chrome_frame_dll_ = |
| 95 new_version_dir.Append(build_chrome_frame_dll.BaseName()); | 95 new_version_dir.Append(build_chrome_frame_dll.BaseName()); |
| 96 ASSERT_TRUE(base::Move(temporary_new_chrome_frame_dll, | 96 ASSERT_TRUE(base::Move(temporary_new_chrome_frame_dll, |
| 97 new_chrome_frame_dll_)); | 97 new_chrome_frame_dll_)); |
| 98 ASSERT_TRUE(file_util::PathExists(new_chrome_frame_dll_)); | 98 ASSERT_TRUE(base::PathExists(new_chrome_frame_dll_)); |
| 99 } | 99 } |
| 100 | 100 |
| 101 static void TearDownTestCase() { | 101 static void TearDownTestCase() { |
| 102 if (!temp_dir_.Delete()) { | 102 if (!temp_dir_.Delete()) { |
| 103 // The temp_dir cleanup has been observed to fail in some cases. It looks | 103 // The temp_dir cleanup has been observed to fail in some cases. It looks |
| 104 // like something is holding on to the Chrome Frame DLLs after they have | 104 // like something is holding on to the Chrome Frame DLLs after they have |
| 105 // been explicitly unloaded. At least schedule them for cleanup on reboot. | 105 // been explicitly unloaded. At least schedule them for cleanup on reboot. |
| 106 ScheduleDirectoryForDeletion(temp_dir_.path().value().c_str()); | 106 ScheduleDirectoryForDeletion(temp_dir_.path().value().c_str()); |
| 107 } | 107 } |
| 108 } | 108 } |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 | 208 |
| 209 char buffer[kSharedMemoryBytes] = {0}; | 209 char buffer[kSharedMemoryBytes] = {0}; |
| 210 memcpy(buffer, beacon.memory(), kSharedMemoryBytes - 1); | 210 memcpy(buffer, beacon.memory(), kSharedMemoryBytes - 1); |
| 211 Version beacon_version(buffer); | 211 Version beacon_version(buffer); |
| 212 ASSERT_TRUE(beacon_version.IsValid()); | 212 ASSERT_TRUE(beacon_version.IsValid()); |
| 213 | 213 |
| 214 EXPECT_EQ(0, | 214 EXPECT_EQ(0, |
| 215 beacon_version.CompareTo(*test_data[i].expected_beacon_version)); | 215 beacon_version.CompareTo(*test_data[i].expected_beacon_version)); |
| 216 } | 216 } |
| 217 } | 217 } |
| OLD | NEW |