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

Unified Diff: chrome/browser/infobars/infobars_browsertest.cc

Issue 10115018: Convert the infobars interactive_ui_test to a browser_test. Remove the ExtensionProxy class which… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/infobars/infobars_browsertest.cc
===================================================================
--- chrome/browser/infobars/infobars_browsertest.cc (revision 132618)
+++ chrome/browser/infobars/infobars_browsertest.cc (working copy)
@@ -2,51 +2,80 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/test/automation/automation_proxy.h"
-#include "chrome/test/automation/browser_proxy.h"
-#include "chrome/test/automation/extension_proxy.h"
-#include "chrome/test/automation/tab_proxy.h"
+#include "chrome/browser/extensions/crx_installer.h"
+#include "chrome/browser/extensions/extension_install_ui.h"
+#include "chrome/browser/extensions/extension_service.h"
+#include "chrome/browser/infobars/infobar_tab_helper.h"
+#include "chrome/browser/themes/theme_service.h"
+#include "chrome/browser/themes/theme_service_factory.h"
+#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
+#include "chrome/common/chrome_notification_types.h"
+#include "chrome/browser/profiles/profile.h"
+#include "content/public/browser/notification_service.h"
+#include "chrome/test/base/in_process_browser_test.h"
+#include "chrome/test/base/ui_test_utils.h"
#include "chrome/test/ui/ui_test.h"
#include "net/test/test_server.h"
-class InfoBarsUITest : public UITest {
+class InfoBarsTest : public InProcessBrowserTest {
public:
- InfoBarsUITest() {
- show_window_ = true;
+ InfoBarsTest() {}
+
+ void InstallExtension(const char* filename) {
+ FilePath path = ui_test_utils::GetTestFilePath(
+ FilePath().AppendASCII("extensions"), FilePath().AppendASCII(filename));
+ Profile* profile = browser()->profile();
+ ExtensionService* service = profile->GetExtensionService();
+
+ ui_test_utils::WindowedNotificationObserver observer(
+ chrome::NOTIFICATION_EXTENSION_LOADED,
+ content::NotificationService::AllSources());
+
+ ExtensionInstallUI* client = new ExtensionInstallUI(profile);
+ scoped_refptr<CrxInstaller> installer(
+ CrxInstaller::Create(service, client));
+ installer->set_install_cause(extension_misc::INSTALL_CAUSE_AUTOMATION);
+ installer->InstallCrx(path);
+
+ observer.Wait();
}
};
-TEST_F(InfoBarsUITest, TestInfoBarsCloseOnNewTheme) {
- net::TestServer test_server(net::TestServer::TYPE_HTTP,
- net::TestServer::kLocalhost,
- FilePath(FILE_PATH_LITERAL("chrome/test/data")));
- ASSERT_TRUE(test_server.Start());
+IN_PROC_BROWSER_TEST_F(InfoBarsTest, TestInfoBarsCloseOnNewTheme) {
+ ASSERT_TRUE(test_server()->Start());
- scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0));
- ASSERT_TRUE(browser.get());
+ ui_test_utils::NavigateToURL(
+ browser(), test_server()->GetURL("files/simple.html"));
- scoped_refptr<TabProxy> tab_1(browser->GetActiveTab());
- ASSERT_TRUE(tab_1.get());
- EXPECT_TRUE(tab_1->NavigateToURL(
- test_server.GetURL("files/simple.html")));
- scoped_refptr<ExtensionProxy> theme = automation()->InstallExtension(
- test_data_directory_.AppendASCII("extensions").AppendASCII("theme.crx"),
- true);
- ASSERT_TRUE(theme != NULL);
- EXPECT_TRUE(tab_1->WaitForInfoBarCount(1));
+ ui_test_utils::WindowedNotificationObserver infobar_added_1(
+ chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED,
+ content::NotificationService::AllSources());
+ InstallExtension("theme.crx");
+ infobar_added_1.Wait();
- EXPECT_TRUE(browser->AppendTab(
- test_server.GetURL("files/simple.html")));
- WaitUntilTabCount(2);
- scoped_refptr<TabProxy> tab_2(browser->GetActiveTab());
- ASSERT_TRUE(tab_2.get());
- theme = automation()->InstallExtension(
- test_data_directory_.AppendASCII("extensions").AppendASCII("theme2.crx"),
- true);
- ASSERT_TRUE(theme != NULL);
- EXPECT_TRUE(tab_2->WaitForInfoBarCount(1));
- EXPECT_TRUE(tab_1->WaitForInfoBarCount(0));
+ ui_test_utils::NavigateToURLWithDisposition(
+ browser(), test_server()->GetURL("files/simple.html"),
+ NEW_FOREGROUND_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
+ ui_test_utils::WindowedNotificationObserver infobar_added_2(
+ chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED,
+ content::NotificationService::AllSources());
+ ui_test_utils::WindowedNotificationObserver infobar_removed_1(
+ chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED,
+ content::NotificationService::AllSources());
+ InstallExtension("theme2.crx");
+ infobar_added_2.Wait();
+ infobar_removed_1.Wait();
+ EXPECT_EQ(0u,
+ browser()->GetTabContentsWrapperAt(0)->infobar_tab_helper()->
+ infobar_count());
- EXPECT_TRUE(automation()->ResetToDefaultTheme());
- EXPECT_TRUE(tab_2->WaitForInfoBarCount(0));
+ ui_test_utils::WindowedNotificationObserver infobar_removed_2(
+ chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED,
+ content::NotificationService::AllSources());
+ ThemeServiceFactory::GetForProfile(browser()->profile())->UseDefaultTheme();
+ infobar_removed_2.Wait();
+ EXPECT_EQ(0u,
+ browser()->GetSelectedTabContentsWrapper()->infobar_tab_helper()->
+ infobar_count());
}
« no previous file with comments | « chrome/browser/automation/automation_provider_observers.cc ('k') | chrome/browser/infobars/infobars_uitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698