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 #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" | 8 #include "chrome/browser/extensions/theme_installed_infobar_delegate.h" |
9 #include "chrome/browser/infobars/infobar_tab_helper.h" | 9 #include "chrome/browser/infobars/infobar_tab_helper.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 // See: http://crbug.com/120647. | 45 // See: http://crbug.com/120647. |
46 #define MAYBE_TestThemeInstallUndoResetsToDefault DISABLED_TestThemeInstallUndoR
esetsToDefault | 46 #define MAYBE_TestThemeInstallUndoResetsToDefault DISABLED_TestThemeInstallUndoR
esetsToDefault |
47 #else | 47 #else |
48 #define MAYBE_TestThemeInstallUndoResetsToDefault TestThemeInstallUndoResetsToDe
fault | 48 #define MAYBE_TestThemeInstallUndoResetsToDefault TestThemeInstallUndoResetsToDe
fault |
49 #endif | 49 #endif |
50 | 50 |
51 IN_PROC_BROWSER_TEST_F(ExtensionInstallUIBrowserTest, | 51 IN_PROC_BROWSER_TEST_F(ExtensionInstallUIBrowserTest, |
52 MAYBE_TestThemeInstallUndoResetsToDefault) { | 52 MAYBE_TestThemeInstallUndoResetsToDefault) { |
53 // Install theme once and undo to verify we go back to default theme. | 53 // Install theme once and undo to verify we go back to default theme. |
54 FilePath theme_crx = PackExtension(test_data_dir_.AppendASCII("theme")); | 54 FilePath theme_crx = PackExtension(test_data_dir_.AppendASCII("theme")); |
55 ASSERT_TRUE(InstallExtensionWithUI(theme_crx, 1)); | 55 ASSERT_TRUE(InstallExtensionWithUIAutoConfirm( |
| 56 theme_crx, 1, browser()->profile())); |
56 const Extension* theme = GetTheme(); | 57 const Extension* theme = GetTheme(); |
57 ASSERT_TRUE(theme); | 58 ASSERT_TRUE(theme); |
58 std::string theme_id = theme->id(); | 59 std::string theme_id = theme->id(); |
59 VerifyThemeInfoBarAndUndoInstall(); | 60 VerifyThemeInfoBarAndUndoInstall(); |
60 ASSERT_EQ(NULL, GetTheme()); | 61 ASSERT_EQ(NULL, GetTheme()); |
61 | 62 |
62 // Set the same theme twice and undo to verify we go back to default theme. | 63 // Set the same theme twice and undo to verify we go back to default theme. |
63 // We set the |expected_change| to zero in these 'InstallExtensionWithUI' | 64 // We set the |expected_change| to zero in these 'InstallExtensionWithUI' |
64 // calls since the theme has already been installed above and this is an | 65 // calls since the theme has already been installed above and this is an |
65 // overinstall to set the active theme. | 66 // overinstall to set the active theme. |
66 ASSERT_TRUE(InstallExtensionWithUI(theme_crx, 0)); | 67 ASSERT_TRUE(InstallExtensionWithUIAutoConfirm( |
| 68 theme_crx, 0, browser()->profile())); |
67 theme = GetTheme(); | 69 theme = GetTheme(); |
68 ASSERT_TRUE(theme); | 70 ASSERT_TRUE(theme); |
69 ASSERT_EQ(theme_id, theme->id()); | 71 ASSERT_EQ(theme_id, theme->id()); |
70 ASSERT_TRUE(InstallExtensionWithUI(theme_crx, 0)); | 72 ASSERT_TRUE(InstallExtensionWithUIAutoConfirm( |
| 73 theme_crx, 0, browser()->profile())); |
71 theme = GetTheme(); | 74 theme = GetTheme(); |
72 ASSERT_TRUE(theme); | 75 ASSERT_TRUE(theme); |
73 ASSERT_EQ(theme_id, theme->id()); | 76 ASSERT_EQ(theme_id, theme->id()); |
74 VerifyThemeInfoBarAndUndoInstall(); | 77 VerifyThemeInfoBarAndUndoInstall(); |
75 ASSERT_EQ(NULL, GetTheme()); | 78 ASSERT_EQ(NULL, GetTheme()); |
76 } | 79 } |
77 | 80 |
78 IN_PROC_BROWSER_TEST_F(ExtensionInstallUIBrowserTest, | 81 IN_PROC_BROWSER_TEST_F(ExtensionInstallUIBrowserTest, |
79 TestThemeInstallUndoResetsToPreviousTheme) { | 82 TestThemeInstallUndoResetsToPreviousTheme) { |
80 // Install first theme. | 83 // Install first theme. |
81 FilePath theme_path = test_data_dir_.AppendASCII("theme"); | 84 FilePath theme_path = test_data_dir_.AppendASCII("theme"); |
82 ASSERT_TRUE(InstallExtensionWithUI(theme_path, 1)); | 85 ASSERT_TRUE(InstallExtensionWithUIAutoConfirm( |
| 86 theme_path, 1, browser()->profile())); |
83 const Extension* theme = GetTheme(); | 87 const Extension* theme = GetTheme(); |
84 ASSERT_TRUE(theme); | 88 ASSERT_TRUE(theme); |
85 std::string theme_id = theme->id(); | 89 std::string theme_id = theme->id(); |
86 | 90 |
87 // Then install second theme. | 91 // Then install second theme. |
88 FilePath theme_path2 = test_data_dir_.AppendASCII("theme2"); | 92 FilePath theme_path2 = test_data_dir_.AppendASCII("theme2"); |
89 ASSERT_TRUE(InstallExtensionWithUI(theme_path2, 1)); | 93 ASSERT_TRUE(InstallExtensionWithUIAutoConfirm( |
| 94 theme_path2, 1, browser()->profile())); |
90 const Extension* theme2 = GetTheme(); | 95 const Extension* theme2 = GetTheme(); |
91 ASSERT_TRUE(theme2); | 96 ASSERT_TRUE(theme2); |
92 EXPECT_FALSE(theme_id == theme2->id()); | 97 EXPECT_FALSE(theme_id == theme2->id()); |
93 | 98 |
94 // Undo second theme will revert to first theme. | 99 // Undo second theme will revert to first theme. |
95 VerifyThemeInfoBarAndUndoInstall(); | 100 VerifyThemeInfoBarAndUndoInstall(); |
96 EXPECT_EQ(theme, GetTheme()); | 101 EXPECT_EQ(theme, GetTheme()); |
97 } | 102 } |
98 | 103 |
99 IN_PROC_BROWSER_TEST_F(ExtensionInstallUIBrowserTest, | 104 IN_PROC_BROWSER_TEST_F(ExtensionInstallUIBrowserTest, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 if (NewTabUI::ShouldShowApps()) { | 137 if (NewTabUI::ShouldShowApps()) { |
133 EXPECT_EQ(num_normal_tabs + 1, browser()->tab_count()); | 138 EXPECT_EQ(num_normal_tabs + 1, browser()->tab_count()); |
134 WebContents* web_contents = browser()->GetSelectedWebContents(); | 139 WebContents* web_contents = browser()->GetSelectedWebContents(); |
135 ASSERT_TRUE(web_contents); | 140 ASSERT_TRUE(web_contents); |
136 EXPECT_TRUE(StartsWithASCII(web_contents->GetURL().spec(), | 141 EXPECT_TRUE(StartsWithASCII(web_contents->GetURL().spec(), |
137 "chrome://newtab/", false)); | 142 "chrome://newtab/", false)); |
138 } else { | 143 } else { |
139 // TODO(xiyuan): Figure out how to test extension installed bubble? | 144 // TODO(xiyuan): Figure out how to test extension installed bubble? |
140 } | 145 } |
141 } | 146 } |
OLD | NEW |