| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include <shlobj.h> // Must be before propkey. | 7 #include <shlobj.h> // Must be before propkey. |
| 8 #include <propkey.h> | 8 #include <propkey.h> |
| 9 #include <shellapi.h> | 9 #include <shellapi.h> |
| 10 | 10 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 base::FilePath(profiles::internal::GetShortcutFilenameForProfile( | 74 base::FilePath(profiles::internal::GetShortcutFilenameForProfile( |
| 75 expected_profile_name, | 75 expected_profile_name, |
| 76 BrowserDistribution::GetDistribution())).RemoveExtension().value(), | 76 BrowserDistribution::GetDistribution())).RemoveExtension().value(), |
| 77 prop_var.get().pwszVal); | 77 prop_var.get().pwszVal); |
| 78 prop_var.Reset(); | 78 prop_var.Reset(); |
| 79 | 79 |
| 80 // The relaunch command should specify the profile. | 80 // The relaunch command should specify the profile. |
| 81 EXPECT_EQ(S_OK, pps->GetValue(PKEY_AppUserModel_RelaunchCommand, | 81 EXPECT_EQ(S_OK, pps->GetValue(PKEY_AppUserModel_RelaunchCommand, |
| 82 prop_var.Receive())); | 82 prop_var.Receive())); |
| 83 EXPECT_EQ(VT_LPWSTR, prop_var.get().vt); | 83 EXPECT_EQ(VT_LPWSTR, prop_var.get().vt); |
| 84 CommandLine cmd_line(CommandLine::FromString(prop_var.get().pwszVal)); | 84 base::CommandLine cmd_line( |
| 85 base::CommandLine::FromString(prop_var.get().pwszVal)); |
| 85 EXPECT_EQ(browser->profile()->GetPath().BaseName().value(), | 86 EXPECT_EQ(browser->profile()->GetPath().BaseName().value(), |
| 86 cmd_line.GetSwitchValueNative(switches::kProfileDirectory)); | 87 cmd_line.GetSwitchValueNative(switches::kProfileDirectory)); |
| 87 prop_var.Reset(); | 88 prop_var.Reset(); |
| 88 | 89 |
| 89 // The app icon should be set to the profile icon. | 90 // The app icon should be set to the profile icon. |
| 90 EXPECT_EQ(S_OK, pps->GetValue(PKEY_AppUserModel_RelaunchIconResource, | 91 EXPECT_EQ(S_OK, pps->GetValue(PKEY_AppUserModel_RelaunchIconResource, |
| 91 prop_var.Receive())); | 92 prop_var.Receive())); |
| 92 EXPECT_EQ(VT_LPWSTR, prop_var.get().vt); | 93 EXPECT_EQ(VT_LPWSTR, prop_var.get().vt); |
| 93 EXPECT_EQ(profiles::internal::GetProfileIconPath( | 94 EXPECT_EQ(profiles::internal::GetProfileIconPath( |
| 94 browser->profile()->GetPath()).value(), | 95 browser->profile()->GetPath()).value(), |
| (...skipping 18 matching lines...) Expand all Loading... |
| 113 prop_var.Receive())); | 114 prop_var.Receive())); |
| 114 EXPECT_EQ(VT_LPWSTR, prop_var.get().vt); | 115 EXPECT_EQ(VT_LPWSTR, prop_var.get().vt); |
| 115 EXPECT_EQ(base::UTF8ToWide(extension->name()), prop_var.get().pwszVal); | 116 EXPECT_EQ(base::UTF8ToWide(extension->name()), prop_var.get().pwszVal); |
| 116 prop_var.Reset(); | 117 prop_var.Reset(); |
| 117 | 118 |
| 118 // The relaunch command should specify the profile and the app id. | 119 // The relaunch command should specify the profile and the app id. |
| 119 EXPECT_EQ( | 120 EXPECT_EQ( |
| 120 S_OK, | 121 S_OK, |
| 121 pps->GetValue(PKEY_AppUserModel_RelaunchCommand, prop_var.Receive())); | 122 pps->GetValue(PKEY_AppUserModel_RelaunchCommand, prop_var.Receive())); |
| 122 EXPECT_EQ(VT_LPWSTR, prop_var.get().vt); | 123 EXPECT_EQ(VT_LPWSTR, prop_var.get().vt); |
| 123 CommandLine cmd_line(CommandLine::FromString(prop_var.get().pwszVal)); | 124 base::CommandLine cmd_line( |
| 125 base::CommandLine::FromString(prop_var.get().pwszVal)); |
| 124 EXPECT_EQ(browser->profile()->GetPath().BaseName().value(), | 126 EXPECT_EQ(browser->profile()->GetPath().BaseName().value(), |
| 125 cmd_line.GetSwitchValueNative(switches::kProfileDirectory)); | 127 cmd_line.GetSwitchValueNative(switches::kProfileDirectory)); |
| 126 EXPECT_EQ(base::UTF8ToWide(extension->id()), | 128 EXPECT_EQ(base::UTF8ToWide(extension->id()), |
| 127 cmd_line.GetSwitchValueNative(switches::kAppId)); | 129 cmd_line.GetSwitchValueNative(switches::kAppId)); |
| 128 prop_var.Reset(); | 130 prop_var.Reset(); |
| 129 | 131 |
| 130 // The app icon should be set to the extension app icon. | 132 // The app icon should be set to the extension app icon. |
| 131 base::FilePath web_app_dir = web_app::GetWebAppDataDirectory( | 133 base::FilePath web_app_dir = web_app::GetWebAppDataDirectory( |
| 132 browser->profile()->GetPath(), extension->id(), GURL()); | 134 browser->profile()->GetPath(), extension->id(), GURL()); |
| 133 EXPECT_EQ(S_OK, | 135 EXPECT_EQ(S_OK, |
| (...skipping 26 matching lines...) Expand all Loading... |
| 160 } | 162 } |
| 161 | 163 |
| 162 } // namespace | 164 } // namespace |
| 163 | 165 |
| 164 // Tests that require the profile shortcut manager to be instantiated despite | 166 // Tests that require the profile shortcut manager to be instantiated despite |
| 165 // having --user-data-dir specified. | 167 // having --user-data-dir specified. |
| 166 class BrowserTestWithProfileShortcutManager : public InProcessBrowserTest { | 168 class BrowserTestWithProfileShortcutManager : public InProcessBrowserTest { |
| 167 public: | 169 public: |
| 168 BrowserTestWithProfileShortcutManager() {} | 170 BrowserTestWithProfileShortcutManager() {} |
| 169 | 171 |
| 170 virtual void SetUpCommandLine(CommandLine* command_line) override { | 172 virtual void SetUpCommandLine(base::CommandLine* command_line) override { |
| 171 command_line->AppendSwitch(switches::kEnableProfileShortcutManager); | 173 command_line->AppendSwitch(switches::kEnableProfileShortcutManager); |
| 172 } | 174 } |
| 173 | 175 |
| 174 private: | 176 private: |
| 175 DISALLOW_COPY_AND_ASSIGN(BrowserTestWithProfileShortcutManager); | 177 DISALLOW_COPY_AND_ASSIGN(BrowserTestWithProfileShortcutManager); |
| 176 }; | 178 }; |
| 177 | 179 |
| 178 // Check that the window properties on Windows are properly set. | 180 // Check that the window properties on Windows are properly set. |
| 179 // http://crbug.com/396344 | 181 // http://crbug.com/396344 |
| 180 IN_PROC_BROWSER_TEST_F(BrowserTestWithProfileShortcutManager, | 182 IN_PROC_BROWSER_TEST_F(BrowserTestWithProfileShortcutManager, |
| 181 DISABLED_WindowProperties) { | 183 DISABLED_WindowProperties) { |
| 182 // Disable this test in Metro+Ash where Windows window properties aren't used. | 184 // Disable this test in Metro+Ash where Windows window properties aren't used. |
| 183 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | 185 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 186 switches::kAshBrowserTests)) |
| 184 return; | 187 return; |
| 185 | 188 |
| 186 // This test checks HWND properties that are only available on Win7+. | 189 // This test checks HWND properties that are only available on Win7+. |
| 187 if (base::win::GetVersion() < base::win::VERSION_WIN7) | 190 if (base::win::GetVersion() < base::win::VERSION_WIN7) |
| 188 return; | 191 return; |
| 189 | 192 |
| 190 // Single profile case. The profile name should not be shown. | 193 // Single profile case. The profile name should not be shown. |
| 191 WaitAndValidateBrowserWindowProperties(base::Bind( | 194 WaitAndValidateBrowserWindowProperties(base::Bind( |
| 192 &ValidateBrowserWindowProperties, browser(), base::string16())); | 195 &ValidateBrowserWindowProperties, browser(), base::string16())); |
| 193 | 196 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 224 WaitAndValidateBrowserWindowProperties( | 227 WaitAndValidateBrowserWindowProperties( |
| 225 base::Bind(&ValidateBrowserWindowProperties, | 228 base::Bind(&ValidateBrowserWindowProperties, |
| 226 profile2_browser, | 229 profile2_browser, |
| 227 cache.GetNameOfProfileAtIndex(profile2_index))); | 230 cache.GetNameOfProfileAtIndex(profile2_index))); |
| 228 } | 231 } |
| 229 | 232 |
| 230 // http://crbug.com/396344 | 233 // http://crbug.com/396344 |
| 231 IN_PROC_BROWSER_TEST_F(BrowserWindowPropertyManagerTest, DISABLED_HostedApp) { | 234 IN_PROC_BROWSER_TEST_F(BrowserWindowPropertyManagerTest, DISABLED_HostedApp) { |
| 232 #if defined(USE_ASH) | 235 #if defined(USE_ASH) |
| 233 // Disable this test in Metro+Ash where Windows window properties aren't used. | 236 // Disable this test in Metro+Ash where Windows window properties aren't used. |
| 234 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | 237 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 238 switches::kAshBrowserTests)) |
| 235 return; | 239 return; |
| 236 #endif | 240 #endif |
| 237 | 241 |
| 238 // This test checks HWND properties that are only available on Win7+. | 242 // This test checks HWND properties that are only available on Win7+. |
| 239 if (base::win::GetVersion() < base::win::VERSION_WIN7) | 243 if (base::win::GetVersion() < base::win::VERSION_WIN7) |
| 240 return; | 244 return; |
| 241 | 245 |
| 242 // Load an app. | 246 // Load an app. |
| 243 const extensions::Extension* extension = | 247 const extensions::Extension* extension = |
| 244 LoadExtension(test_data_dir_.AppendASCII("app/")); | 248 LoadExtension(test_data_dir_.AppendASCII("app/")); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 259 for (chrome::BrowserIterator it; !it.done() && !app_browser; it.Next()) { | 263 for (chrome::BrowserIterator it; !it.done() && !app_browser; it.Next()) { |
| 260 if (*it != browser()) | 264 if (*it != browser()) |
| 261 app_browser = *it; | 265 app_browser = *it; |
| 262 } | 266 } |
| 263 ASSERT_TRUE(app_browser); | 267 ASSERT_TRUE(app_browser); |
| 264 ASSERT_TRUE(app_browser != browser()); | 268 ASSERT_TRUE(app_browser != browser()); |
| 265 | 269 |
| 266 WaitAndValidateBrowserWindowProperties( | 270 WaitAndValidateBrowserWindowProperties( |
| 267 base::Bind(&ValidateHostedAppWindowProperties, app_browser, extension)); | 271 base::Bind(&ValidateHostedAppWindowProperties, app_browser, extension)); |
| 268 } | 272 } |
| OLD | NEW |