Cast: Stop logging kVideoFrameSentToEncoder and rename a couple events.
[chromium-blink-merge.git] / chrome / browser / ui / webui / options / clear_browser_data_browsertest.cc
blobff33e276047db74945f886a03d6b950d3c484759
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/browsing_data/browsing_data_remover_test_util.h"
6 #include "chrome/browser/ui/webui/options/options_ui_browsertest.h"
7 #include "chrome/common/url_constants.h"
8 #include "content/public/test/browser_test_utils.h"
10 namespace options {
12 class ClearBrowserDataBrowserTest : public OptionsUIBrowserTest {
13 protected:
14 void ClickElement(const std::string& selector) {
15 bool element_enabled = false;
16 ASSERT_NO_FATAL_FAILURE(GetElementEnabledState(selector, &element_enabled));
17 ASSERT_TRUE(element_enabled);
18 ASSERT_TRUE(content::ExecuteScript(
19 GetSettingsFrame(),
20 "document.querySelector('" + selector + "').click();"));
23 bool IsElementEnabled(const std::string& selector) {
24 bool element_enabled = false;
25 GetElementEnabledState(selector, &element_enabled);
26 return element_enabled;
29 private:
30 void GetElementEnabledState(
31 const std::string& selector,
32 bool* enabled) {
33 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
34 GetSettingsFrame(),
35 "window.domAutomationController.send(!document.querySelector('" +
36 selector + "').disabled);",
37 enabled));
41 IN_PROC_BROWSER_TEST_F(ClearBrowserDataBrowserTest,
42 CommitButtonDisabledWhileDeletionInProgress) {
43 const char kCommitButtonId[] = "#clear-browser-data-commit";
44 BrowsingDataRemoverCompletionInhibitor completion_inhibitor;
46 // Navigate to the Clear Browsing Data dialog to ensure that the commit button
47 // is initially enabled, usable, and gets disabled after having been pressed.
48 NavigateToSettingsSubpage(chrome::kClearBrowserDataSubPage);
49 ASSERT_NO_FATAL_FAILURE(ClickElement(kCommitButtonId));
50 EXPECT_FALSE(IsElementEnabled(kCommitButtonId));
52 completion_inhibitor.BlockUntilNearCompletion();
54 // Simulate a reload while the previous removal is still running, and verify
55 // that the button is still disabled.
56 NavigateToSettingsSubpage(chrome::kClearBrowserDataSubPage);
57 EXPECT_FALSE(IsElementEnabled(kCommitButtonId));
59 completion_inhibitor.ContinueToCompletion();
61 // However, the button should be enabled again once the process has finished.
62 NavigateToSettingsSubpage(chrome::kClearBrowserDataSubPage);
63 EXPECT_TRUE(IsElementEnabled(kCommitButtonId));
66 } // namespace options