Chromium Code Reviews| Index: chrome/installer/util/shell_util_unittest.cc |
| diff --git a/chrome/installer/util/shell_util_unittest.cc b/chrome/installer/util/shell_util_unittest.cc |
| index 298a9a4ffd96dca4b4c7a5d74bb539a1661fa586..9c0eb34afd2bce1e4da5d3ba4211f7ea357a45c8 100644 |
| --- a/chrome/installer/util/shell_util_unittest.cc |
| +++ b/chrome/installer/util/shell_util_unittest.cc |
| @@ -2,14 +2,13 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -#include <shlobj.h> |
| - |
| #include <fstream> |
| #include <vector> |
| #include "base/file_util.h" |
| #include "base/path_service.h" |
| #include "base/md5.h" |
| +#include "base/path_service.h" |
| #include "base/scoped_temp_dir.h" |
| #include "base/string16.h" |
| #include "base/string_util.h" |
| @@ -24,17 +23,27 @@ |
| namespace { |
| -class ShellUtilTestWithDirAndDist : public testing::Test { |
| +class ShellUtilShortcutTest : public testing::Test { |
| protected: |
| virtual void SetUp() { |
|
grt (UTC plus 2)
2012/09/19 16:44:46
OVERRIDE
gab
2012/09/19 18:22:58
Done (and also done in profile_shorcut_manager_uni
|
| - ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| dist_ = BrowserDistribution::GetDistribution(); |
| ASSERT_TRUE(dist_ != NULL); |
| + |
| + ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| + ASSERT_TRUE(fake_user_desktop_.CreateUniqueTempDir()); |
| + ASSERT_TRUE(fake_common_desktop_.CreateUniqueTempDir()); |
| + EXPECT_TRUE(PathService::Override(base::DIR_USER_DESKTOP, |
|
grt (UTC plus 2)
2012/09/19 16:44:46
why not ASSERT_TRUE? should the test continue if
gab
2012/09/19 18:22:58
Well the test as a whole can still pass if Overrid
|
| + fake_user_desktop_.path())); |
| + EXPECT_TRUE(PathService::Override(base::DIR_COMMON_DESKTOP, |
| + fake_common_desktop_.path())); |
| } |
| BrowserDistribution* dist_; |
| ScopedTempDir temp_dir_; |
| + |
| + ScopedTempDir fake_user_desktop_; |
| + ScopedTempDir fake_common_desktop_; |
| }; |
| // Returns the status of a call to base::win::VerifyShorcut for the properties |
| @@ -58,7 +67,7 @@ base::win::VerifyShortcutStatus VerifyChromeShortcut( |
| } |
| // Test that we can open archives successfully. |
| -TEST_F(ShellUtilTestWithDirAndDist, UpdateChromeShortcutTest) { |
| +TEST_F(ShellUtilShortcutTest, UpdateChromeShortcut) { |
| // Create an executable in test path by copying ourself to it. |
| wchar_t exe_full_path_str[MAX_PATH]; |
| EXPECT_FALSE(::GetModuleFileName(NULL, exe_full_path_str, MAX_PATH) == 0); |
| @@ -122,13 +131,7 @@ TEST_F(ShellUtilTestWithDirAndDist, UpdateChromeShortcutTest) { |
| VerifyChromeShortcut(exe_path, shortcut_path, description2, 1)); |
| } |
| -TEST_F(ShellUtilTestWithDirAndDist, CreateChromeDesktopShortcutTest) { |
| - // Run this test on Vista+ only if we are running elevated. |
| - if (base::win::GetVersion() > base::win::VERSION_XP && !IsUserAnAdmin()) { |
| - LOG(ERROR) << "Must be admin to run this test on Vista+"; |
| - return; |
| - } |
| - |
| +TEST_F(ShellUtilShortcutTest, CreateChromeDesktopShortcut) { |
| // Create an executable in test path by copying ourself to it. |
| wchar_t exe_full_path_str[MAX_PATH]; |
| EXPECT_FALSE(::GetModuleFileName(NULL, exe_full_path_str, MAX_PATH) == 0); |
| @@ -306,16 +309,18 @@ TEST_F(ShellUtilTestWithDirAndDist, CreateChromeDesktopShortcutTest) { |
| profile_names)); |
| } |
| -TEST_F(ShellUtilTestWithDirAndDist, BuildAppModelIdBasic) { |
| +TEST(ShellUtilTest, BuildAppModelIdBasic) { |
| std::vector<string16> components; |
| - const string16 base_app_id(dist_->GetBaseAppId()); |
| + BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
| + const string16 base_app_id(dist->GetBaseAppId()); |
| components.push_back(base_app_id); |
| ASSERT_EQ(base_app_id, ShellUtil::BuildAppModelId(components)); |
| } |
| -TEST_F(ShellUtilTestWithDirAndDist, BuildAppModelIdManySmall) { |
| +TEST(ShellUtilTest, BuildAppModelIdManySmall) { |
| std::vector<string16> components; |
| - const string16 suffixed_app_id(dist_->GetBaseAppId().append(L".gab")); |
| + BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
| + const string16 suffixed_app_id(dist->GetBaseAppId().append(L".gab")); |
| components.push_back(suffixed_app_id); |
| components.push_back(L"Default"); |
| components.push_back(L"Test"); |
| @@ -323,7 +328,7 @@ TEST_F(ShellUtilTestWithDirAndDist, BuildAppModelIdManySmall) { |
| ShellUtil::BuildAppModelId(components)); |
| } |
| -TEST_F(ShellUtilTestWithDirAndDist, BuildAppModelIdLongUsernameNormalProfile) { |
| +TEST(ShellUtilTest, BuildAppModelIdLongUsernameNormalProfile) { |
| std::vector<string16> components; |
| const string16 long_appname( |
| L"Chrome.a_user_who_has_a_crazy_long_name_with_some_weird@symbols_in_it_" |
| @@ -334,7 +339,7 @@ TEST_F(ShellUtilTestWithDirAndDist, BuildAppModelIdLongUsernameNormalProfile) { |
| ShellUtil::BuildAppModelId(components)); |
| } |
| -TEST_F(ShellUtilTestWithDirAndDist, BuildAppModelIdLongEverything) { |
| +TEST(ShellUtilTest, BuildAppModelIdLongEverything) { |
| std::vector<string16> components; |
| const string16 long_appname( |
| L"Chrome.a_user_who_has_a_crazy_long_name_with_some_weird@symbols_in_it_" |