1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
|
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_EXTENSIONS_EXTENSION_MESSAGE_BUBBLE_BROWSERTEST_H_
#define CHROME_BROWSER_UI_EXTENSIONS_EXTENSION_MESSAGE_BUBBLE_BROWSERTEST_H_
#include <memory>
#include "base/macros.h"
#include "chrome/browser/ui/toolbar/browser_actions_bar_browsertest.h"
namespace extensions {
class TestExtensionDir;
}
class ExtensionMessageBubbleBrowserTest
: public BrowserActionsBarBrowserTest {
protected:
enum AnchorPosition {
ANCHOR_BROWSER_ACTION,
ANCHOR_APP_MENU,
};
ExtensionMessageBubbleBrowserTest();
~ExtensionMessageBubbleBrowserTest() override;
// BrowserActionsBarBrowserTest:
void SetUpCommandLine(base::CommandLine* command_line) override;
void TearDownOnMainThread() override;
// Checks the position of the bubble present in the given |browser|, when the
// bubble should be anchored at the given |anchor| and that the toolbar model
// is correctly highlighting.
void CheckBubble(Browser* browser,
AnchorPosition anchor,
bool should_be_highlighting);
// Performs the platform-specific checks.
virtual void CheckBubbleNative(Browser* browser, AnchorPosition anchor) = 0;
// Closes the bubble present in the given |browser|.
void CloseBubble(Browser* browser);
// Performs the platform-specific close.
virtual void CloseBubbleNative(Browser* browser) = 0;
// Checks that there is no active bubble for the given |browser|.
// We specify whether or not the toolbar model should be highlighting or there
// is a bubble active since another browser window may have an active bubble.
void CheckBubbleIsNotPresent(Browser* browser,
bool should_profile_have_bubble,
bool should_be_highlighting);
// Performs the platform-specific checks.
virtual void CheckBubbleIsNotPresentNative(Browser* browser) = 0;
// Clicks on the corresponding button in the bubble.
virtual void ClickLearnMoreButton(Browser* browser) = 0;
virtual void ClickActionButton(Browser* browser) = 0;
virtual void ClickDismissButton(Browser* browser) = 0;
// Adds a new extension that uses the chrome_settings_overrides api to
// override a setting specified in |settings_override_value|.
void AddSettingsOverrideExtension(const std::string& settings_override_value);
// The following are essentially the different tests, but we can't define the
// tests in this file, since it relies on platform-specific implementation
// (the above virtual methods).
// Tests that an extension bubble will be anchored to an extension action when
// there are extensions with actions.
void TestBubbleAnchoredToExtensionAction();
// Tests that an extension bubble will be anchored to the app menu when there
// aren't any extensions with actions.
// This also tests that the crashes in crbug.com/476426 are fixed.
void TestBubbleAnchoredToAppMenu();
// Tests that an extension bubble will be anchored to the app menu if there
// are no highlighted extensions, even if there's a benevolent extension with
// an action.
// Regression test for crbug.com/485614.
void TestBubbleAnchoredToAppMenuWithOtherAction();
// Tests that uninstalling the extension between when the bubble is originally
// slated to show and when it does show is handled gracefully.
// Regression test for crbug.com/531648.
void TestUninstallDangerousExtension();
// Tests that the extension bubble will show on startup.
void PreBubbleShowsOnStartup();
void TestBubbleShowsOnStartup();
// Tests that the developer mode warning bubble is only shown once per
// profile.
// Regression test for crbug.com/607099.
void TestDevModeBubbleIsntShownTwice();
// Tests that the bubble indicating an extension is controlling a user's
// new tab page is shown.
void TestControlledNewTabPageBubbleShown();
// Tests that the bubble indicating an extension is controlling a user's
// home page is shown.
void TestControlledHomeBubbleShown();
// Tests that the bubble indicating an extension is controlling a user's
// search engine is shown.
void TestControlledSearchBubbleShown();
// Tests that the bubble indicating an extension is controlling a user's
// startup pages is shown.
void PreTestControlledStartupBubbleShown();
void TestControlledStartupBubbleShown();
// Tests that the startup controlled bubble is *not* shown in the case of a
// browser restart, since restarts always result in a session restore rather
// than showing the normal startup pages.
void PreTestControlledStartupNotShownOnRestart();
void TestControlledStartupNotShownOnRestart();
// Tests that having multiple windows, all of which could be vying to show a
// warning bubble, behaves properly.
void TestBubbleWithMultipleWindows();
// Tests clicking on the corresponding button in the bubble view. The logic
// for these is tested more thoroughly in the unit tests, but this ensures
// that nothing goes wrong end-to-end.
void TestClickingLearnMoreButton();
void TestClickingActionButton();
void TestClickingDismissButton();
private:
std::unique_ptr<extensions::FeatureSwitch::ScopedOverride>
dev_mode_bubble_override_;
// The backing directory for a custom extension loaded during a test. Null if
// no custom extension is loaded.
std::unique_ptr<extensions::TestExtensionDir> custom_extension_dir_;
DISALLOW_COPY_AND_ASSIGN(ExtensionMessageBubbleBrowserTest);
};
#endif // CHROME_BROWSER_UI_EXTENSIONS_EXTENSION_MESSAGE_BUBBLE_BROWSERTEST_H_
|