Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(216)

Side by Side Diff: chrome/browser/ui/browser_browsertest.cc

Issue 13864015: Move app launcher and chrome apps shortcut strings into the installer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@migrate_app_id_fix
Patch Set: fix linux Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include <string> 5 #include <string>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 #include "net/test/spawned_test_server/spawned_test_server.h" 81 #include "net/test/spawned_test_server/spawned_test_server.h"
82 #include "ui/base/l10n/l10n_util.h" 82 #include "ui/base/l10n/l10n_util.h"
83 83
84 #if defined(OS_MACOSX) 84 #if defined(OS_MACOSX)
85 #include "base/mac/mac_util.h" 85 #include "base/mac/mac_util.h"
86 #include "base/mac/scoped_nsautorelease_pool.h" 86 #include "base/mac/scoped_nsautorelease_pool.h"
87 #include "chrome/browser/ui/cocoa/run_loop_testing.h" 87 #include "chrome/browser/ui/cocoa/run_loop_testing.h"
88 #endif 88 #endif
89 89
90 #if defined(OS_WIN) 90 #if defined(OS_WIN)
91 #include <shlobj.h> // Must be before propkey.
92 #include <propkey.h>
93 #include <shellapi.h>
94
91 #include "base/i18n/rtl.h" 95 #include "base/i18n/rtl.h"
96 #include "base/win/scoped_comptr.h"
97 #include "base/win/scoped_propvariant.h"
98 #include "base/win/windows_version.h"
92 #include "chrome/browser/browser_process.h" 99 #include "chrome/browser/browser_process.h"
100 #include "chrome/browser/profiles/profile_shortcut_manager_win.h"
101 #include "chrome/browser/profiles/profiles_state.h"
102 #include "chrome/installer/util/browser_distribution.h"
103 #include "ui/views/win/hwnd_util.h"
93 #endif 104 #endif
94 105
95 using content::InterstitialPage; 106 using content::InterstitialPage;
96 using content::HostZoomMap; 107 using content::HostZoomMap;
97 using content::NavigationController; 108 using content::NavigationController;
98 using content::NavigationEntry; 109 using content::NavigationEntry;
99 using content::OpenURLParams; 110 using content::OpenURLParams;
100 using content::Referrer; 111 using content::Referrer;
101 using content::WebContents; 112 using content::WebContents;
102 using content::WebContentsObserver; 113 using content::WebContentsObserver;
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 330
320 typedef std::map<content::RenderViewHost*, Sizes> RenderViewSizes; 331 typedef std::map<content::RenderViewHost*, Sizes> RenderViewSizes;
321 RenderViewSizes render_view_sizes_; 332 RenderViewSizes render_view_sizes_;
322 // Enlarge WebContentsView by this size insets in NavigateToPendingEntry. 333 // Enlarge WebContentsView by this size insets in NavigateToPendingEntry.
323 gfx::Size wcv_resize_insets_; 334 gfx::Size wcv_resize_insets_;
324 BrowserWindow* browser_window_; // Weak ptr. 335 BrowserWindow* browser_window_; // Weak ptr.
325 336
326 DISALLOW_COPY_AND_ASSIGN(RenderViewSizeObserver); 337 DISALLOW_COPY_AND_ASSIGN(RenderViewSizeObserver);
327 }; 338 };
328 339
340 #if defined(OS_WIN)
gab 2013/10/17 15:13:31 Wait... isn't this part of the other change you're
calamity 2013/11/20 05:43:30 Removed.
341
342 // An observer that returns back to test code after a new profile is
343 // initialized.
344 void UnblockOnProfileCreation(Profile* profile,
345 Profile::CreateStatus status) {
346 if (status == Profile::CREATE_STATUS_INITIALIZED)
347 base::MessageLoop::current()->Quit();
348 }
349
350 // Checks that the relaunch name, relaunch command and app icon for the given
351 // |browser| are correct.
352 void ValidateBrowserWindowProperties(
353 Browser* browser,
354 const base::string16& expected_profile_name) {
355 HWND hwnd = views::HWNDForNativeWindow(browser->window()->GetNativeWindow());
356
357 base::win::ScopedComPtr<IPropertyStore> pps;
358 HRESULT result = SHGetPropertyStoreForWindow(hwnd, IID_IPropertyStore,
359 pps.ReceiveVoid());
360 EXPECT_TRUE(SUCCEEDED(result));
361
362 base::win::ScopedPropVariant prop_var;
363 // The relaunch name should be of the form "Chromium" if there is only 1
364 // profile and "First User - Chromium" if there are more. The expected value
365 // is given by |expected_profile_name|.
366 EXPECT_EQ(S_OK, pps->GetValue(PKEY_AppUserModel_RelaunchDisplayNameResource,
367 prop_var.Receive()));
368 EXPECT_EQ(VT_LPWSTR, prop_var.get().vt);
369 EXPECT_EQ(
370 base::FilePath(profiles::GetShortcutFilenameForProfile(
371 expected_profile_name,
372 BrowserDistribution::GetDistribution())).RemoveExtension().value(),
373 prop_var.get().pwszVal);
374 prop_var.Reset();
375
376 // The relaunch command should specify the profile.
377 EXPECT_EQ(S_OK, pps->GetValue(PKEY_AppUserModel_RelaunchCommand,
378 prop_var.Receive()));
379 EXPECT_EQ(VT_LPWSTR, prop_var.get().vt);
380 CommandLine cmd_line(CommandLine::FromString(prop_var.get().pwszVal));
381 EXPECT_EQ(browser->profile()->GetPath().BaseName().value(),
382 cmd_line.GetSwitchValueNative(switches::kProfileDirectory));
383 prop_var.Reset();
384
385 // The app icon should be set to the profile icon.
386 EXPECT_EQ(S_OK, pps->GetValue(PKEY_AppUserModel_RelaunchIconResource,
387 prop_var.Receive()));
388 EXPECT_EQ(VT_LPWSTR, prop_var.get().vt);
389 EXPECT_EQ(profiles::GetProfileIconPath(browser->profile()->GetPath()).value(),
390 prop_var.get().pwszVal);
391 prop_var.Reset();
392 }
393
394 #endif
395
329 } // namespace 396 } // namespace
330 397
331 class BrowserTest : public ExtensionBrowserTest { 398 class BrowserTest : public ExtensionBrowserTest {
332 protected: 399 protected:
333 // In RTL locales wrap the page title with RTL embedding characters so that it 400 // In RTL locales wrap the page title with RTL embedding characters so that it
334 // matches the value returned by GetWindowTitle(). 401 // matches the value returned by GetWindowTitle().
335 string16 LocaleWindowCaptionFromPageTitle(const string16& expected_title) { 402 string16 LocaleWindowCaptionFromPageTitle(const string16& expected_title) {
336 string16 page_title = WindowCaptionFromPageTitle(expected_title); 403 string16 page_title = WindowCaptionFromPageTitle(expected_title);
337 #if defined(OS_WIN) 404 #if defined(OS_WIN)
338 std::string locale = g_browser_process->GetApplicationLocale(); 405 std::string locale = g_browser_process->GetApplicationLocale();
(...skipping 2163 matching lines...) Expand 10 before | Expand all | Expand 10 after
2502 exp_commit_size.Enlarge(wcv_resize_insets.width(), 2569 exp_commit_size.Enlarge(wcv_resize_insets.width(),
2503 wcv_resize_insets.height() + height_inset); 2570 wcv_resize_insets.height() + height_inset);
2504 EXPECT_EQ(exp_commit_size, rwhv_commit_size2); 2571 EXPECT_EQ(exp_commit_size, rwhv_commit_size2);
2505 EXPECT_EQ(exp_commit_size, wcv_commit_size2); 2572 EXPECT_EQ(exp_commit_size, wcv_commit_size2);
2506 // Sizes of RenderWidgetHostView and WebContentsView before and after 2573 // Sizes of RenderWidgetHostView and WebContentsView before and after
2507 // WebContentsDelegate::DidNavigateMainFramePostCommit should be the same. 2574 // WebContentsDelegate::DidNavigateMainFramePostCommit should be the same.
2508 EXPECT_EQ(rwhv_commit_size2, 2575 EXPECT_EQ(rwhv_commit_size2,
2509 web_contents->GetRenderWidgetHostView()->GetViewBounds().size()); 2576 web_contents->GetRenderWidgetHostView()->GetViewBounds().size());
2510 EXPECT_EQ(wcv_commit_size2, web_contents->GetView()->GetContainerSize()); 2577 EXPECT_EQ(wcv_commit_size2, web_contents->GetView()->GetContainerSize());
2511 } 2578 }
2579
2580 #if defined(OS_WIN)
2581
2582 // Check that the window properties on Windows are properly set.
2583 IN_PROC_BROWSER_TEST_F(BrowserTest, WindowProperties) {
2584 #if defined(USE_ASH)
2585 // Disable this test in Metro+Ash where Windows window properties aren't used.
2586 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests))
2587 return;
2588 #endif
2589
2590 // This test checks HWND properties that are only available on Win7+.
2591 if (base::win::GetVersion() < base::win::VERSION_WIN7)
2592 return;
2593
2594 // Single profile case. The profile name should not be shown.
2595 ValidateBrowserWindowProperties(browser(), base::string16());
2596
2597 // If multiprofile mode is not enabled, we can't test the behavior when there
2598 // are multiple profiles.
2599 if (!profiles::IsMultipleProfilesEnabled())
2600 return;
2601
2602 // Two profile case. Both profile names should be shown.
2603 ProfileManager* profile_manager = g_browser_process->profile_manager();
2604 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache();
2605
2606 base::FilePath path_profile2 =
2607 profile_manager->GenerateNextProfileDirectoryPath();
2608 profile_manager->CreateProfileAsync(path_profile2,
2609 base::Bind(&UnblockOnProfileCreation),
2610 string16(), string16(), std::string());
2611
2612 // Spin to allow profile creation to take place, loop is terminated
2613 // by UnblockOnProfileCreation when the profile is created.
2614 content::RunMessageLoop();
2615
2616 // The default profile's name should be part of the relaunch name.
2617 ValidateBrowserWindowProperties(
2618 browser(), UTF8ToUTF16(browser()->profile()->GetProfileName()));
2619
2620 // The second profile's name should be part of the relaunch name.
2621 Browser* profile2_browser =
2622 CreateBrowser(profile_manager->GetProfileByPath(path_profile2));
2623 size_t profile2_index = cache.GetIndexOfProfileWithPath(path_profile2);
2624 ValidateBrowserWindowProperties(
2625 profile2_browser, cache.GetNameOfProfileAtIndex(profile2_index));
2626 }
2627
2628 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698