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

Side by Side Diff: chrome/browser/extensions/extension_install_ui_browsertest.cc

Issue 6546072: Clean up how we handle themes in the extensions system and management API.... Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 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 "base/string_util.h" 5 #include "base/string_util.h"
6 #include "chrome/browser/extensions/extension_browsertest.h" 6 #include "chrome/browser/extensions/extension_browsertest.h"
7 #include "chrome/browser/extensions/extension_service.h" 7 #include "chrome/browser/extensions/extension_service.h"
8 #include "chrome/browser/extensions/theme_installed_infobar_delegate.h"
9 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/tab_contents/tab_contents.h" 9 #include "chrome/browser/tab_contents/tab_contents.h"
11 #include "chrome/browser/ui/browser.h" 10 #include "chrome/browser/ui/browser.h"
12 #include "chrome/test/ui_test_utils.h" 11 #include "chrome/test/ui_test_utils.h"
13 12
14 namespace { 13 namespace {
15 14
16 } // namespace 15 } // namespace
17 16
18 class ExtensionInstallUIBrowserTest : public ExtensionBrowserTest { 17 class ExtensionInstallUIBrowserTest : public ExtensionBrowserTest {};
19 public:
20 // Checks that a theme info bar is currently visible and issues an undo to
21 // revert to the previous theme.
22 void VerifyThemeInfoBarAndUndoInstall() {
23 TabContents* tab_contents = browser()->GetSelectedTabContents();
24 ASSERT_TRUE(tab_contents);
25 ASSERT_EQ(1U, tab_contents->infobar_count());
26 ConfirmInfoBarDelegate* delegate =
27 tab_contents->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate();
28 ASSERT_TRUE(delegate);
29 delegate->Cancel();
30 ASSERT_EQ(0U, tab_contents->infobar_count());
31 }
32 };
33 18
34 IN_PROC_BROWSER_TEST_F(ExtensionInstallUIBrowserTest, 19 IN_PROC_BROWSER_TEST_F(ExtensionInstallUIBrowserTest,
35 TestThemeInstallUndoResetsToDefault) { 20 TestThemeInstallUndoResetsToDefault) {
36 // Install theme once and undo to verify we go back to default theme. 21 // Install theme once and undo to verify we go back to default theme.
37 FilePath theme_crx = PackExtension(test_data_dir_.AppendASCII("theme")); 22 FilePath theme_crx = PackExtension(test_data_dir_.AppendASCII("theme"));
38 ASSERT_TRUE(InstallExtensionWithUI(theme_crx, 1)); 23 ASSERT_TRUE(InstallExtensionWithUI(theme_crx, 1));
39 const Extension* theme = browser()->profile()->GetTheme(); 24 const Extension* theme = browser()->profile()->GetTheme();
40 ASSERT_TRUE(theme); 25 ASSERT_TRUE(theme);
41 std::string theme_id = theme->id(); 26 std::string theme_id = theme->id();
42 VerifyThemeInfoBarAndUndoInstall(); 27 VerifyThemeInfoBarAndUndoInstall();
43 ASSERT_EQ(NULL, browser()->profile()->GetTheme()); 28 ASSERT_EQ(NULL, browser()->profile()->GetTheme());
44 29
45 // Set the same theme twice and undo to verify we go back to default theme. 30 // Set the same theme twice and undo to verify we go back to default theme.
46 // We set the |expected_change| to zero in these 'InstallExtensionWithUI' 31 // We set the |expected_change| to zero in these 'InstallExtensionWithUI'
47 // calls since the theme has already been installed above and this is an 32 // calls since the theme has already been installed above and this is an
48 // overinstall to set the active theme. 33 // overinstall to set the active theme.
49 ASSERT_TRUE(InstallExtensionWithUI(theme_crx, 0)); 34 ASSERT_TRUE(InstallExtensionWithUI(theme_crx, 1));
50 theme = browser()->profile()->GetTheme(); 35 theme = browser()->profile()->GetTheme();
51 ASSERT_TRUE(theme); 36 ASSERT_TRUE(theme);
52 ASSERT_EQ(theme_id, theme->id()); 37 ASSERT_EQ(theme_id, theme->id());
53 ASSERT_TRUE(InstallExtensionWithUI(theme_crx, 0)); 38 ASSERT_TRUE(InstallExtensionWithUI(theme_crx, 0));
54 theme = browser()->profile()->GetTheme(); 39 theme = browser()->profile()->GetTheme();
55 ASSERT_TRUE(theme); 40 ASSERT_TRUE(theme);
56 ASSERT_EQ(theme_id, theme->id()); 41 ASSERT_EQ(theme_id, theme->id());
57 VerifyThemeInfoBarAndUndoInstall(); 42 VerifyThemeInfoBarAndUndoInstall();
58 ASSERT_EQ(NULL, browser()->profile()->GetTheme()); 43 ASSERT_EQ(NULL, browser()->profile()->GetTheme());
59 } 44 }
60 45
61 IN_PROC_BROWSER_TEST_F(ExtensionInstallUIBrowserTest, 46 IN_PROC_BROWSER_TEST_F(ExtensionInstallUIBrowserTest,
62 TestThemeInstallUndoResetsToPreviousTheme) { 47 TestThemeInstallUndoResetsToPreviousTheme) {
63 // Install first theme. 48 // Install first theme.
64 FilePath theme_path = test_data_dir_.AppendASCII("theme"); 49 FilePath theme_path = test_data_dir_.AppendASCII("theme");
65 ASSERT_TRUE(InstallExtensionWithUI(theme_path, 1)); 50 ASSERT_TRUE(InstallExtensionWithUI(theme_path, 1));
66 const Extension* theme = browser()->profile()->GetTheme(); 51 const Extension* theme = browser()->profile()->GetTheme();
67 ASSERT_TRUE(theme); 52 ASSERT_TRUE(theme);
68 std::string theme_id = theme->id(); 53 std::string theme_id = theme->id();
69 54
70 // Then install second theme. 55 // Then install second theme.
71 FilePath theme_path2 = test_data_dir_.AppendASCII("theme2"); 56 FilePath theme_path2 = test_data_dir_.AppendASCII("theme2");
72 ASSERT_TRUE(InstallExtensionWithUI(theme_path2, 1)); 57 ASSERT_TRUE(InstallExtensionWithUI(theme_path2, 0));
73 const Extension* theme2 = browser()->profile()->GetTheme(); 58 const Extension* theme2 = browser()->profile()->GetTheme();
74 ASSERT_TRUE(theme2); 59 ASSERT_TRUE(theme2);
75 EXPECT_FALSE(theme_id == theme2->id()); 60 EXPECT_FALSE(theme_id == theme2->id());
76 61
77 // Undo second theme will revert to first theme. 62 // Undo second theme will revert to first theme.
78 VerifyThemeInfoBarAndUndoInstall(); 63 VerifyThemeInfoBarAndUndoInstall();
79 EXPECT_EQ(theme, browser()->profile()->GetTheme()); 64 EXPECT_EQ(theme, browser()->profile()->GetTheme());
80 } 65 }
81 66
82 IN_PROC_BROWSER_TEST_F(ExtensionInstallUIBrowserTest, 67 IN_PROC_BROWSER_TEST_F(ExtensionInstallUIBrowserTest,
(...skipping 26 matching lines...) Expand all
109 incognito_profile)); 94 incognito_profile));
110 95
111 EXPECT_EQ(num_incognito_tabs, incognito_browser->tab_count()); 96 EXPECT_EQ(num_incognito_tabs, incognito_browser->tab_count());
112 EXPECT_EQ(num_normal_tabs + 1, browser()->tab_count()); 97 EXPECT_EQ(num_normal_tabs + 1, browser()->tab_count());
113 TabContents* tab_contents = browser()->GetSelectedTabContents(); 98 TabContents* tab_contents = browser()->GetSelectedTabContents();
114 ASSERT_TRUE(tab_contents); 99 ASSERT_TRUE(tab_contents);
115 EXPECT_TRUE(StartsWithASCII(tab_contents->GetURL().spec(), 100 EXPECT_TRUE(StartsWithASCII(tab_contents->GetURL().spec(),
116 "chrome://newtab/#app-id=", // id changes 101 "chrome://newtab/#app-id=", // id changes
117 false)); 102 false));
118 } 103 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_browsertest.cc ('k') | chrome/browser/extensions/extension_management_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698