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

Unified Diff: chrome/browser/ui/cocoa/location_bar/content_setting_decoration_browsertest.mm

Issue 2651333004: [Mac] Test for Content Setting Decoration (Closed)
Patch Set: 2016 -> 2017 Created 3 years, 11 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
« no previous file with comments | « chrome/browser/ui/cocoa/location_bar/content_setting_decoration.h ('k') | chrome/test/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/cocoa/location_bar/content_setting_decoration_browsertest.mm
diff --git a/chrome/browser/ui/cocoa/location_bar/content_setting_decoration_browsertest.mm b/chrome/browser/ui/cocoa/location_bar/content_setting_decoration_browsertest.mm
new file mode 100644
index 0000000000000000000000000000000000000000..916d33d5c1beaa684acd279084d0265ea6f5b2cb
--- /dev/null
+++ b/chrome/browser/ui/cocoa/location_bar/content_setting_decoration_browsertest.mm
@@ -0,0 +1,63 @@
+// Copyright 2017 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.
+
+#import "chrome/browser/ui/cocoa/location_bar/content_setting_decoration.h"
+
+#include "chrome/browser/ui/browser_window.h"
+#import "chrome/browser/ui/cocoa/browser_window_controller.h"
+#import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h"
+#include "chrome/browser/ui/content_settings/content_setting_image_model.h"
+#include "chrome/test/base/in_process_browser_test.h"
+#include "content/public/test/test_utils.h"
+
+class ContentSettingDecorationTest : public InProcessBrowserTest {
+ protected:
+ ContentSettingDecorationTest() : InProcessBrowserTest() {}
+
+ void SetUpOnMainThread() override {
+ std::unique_ptr<ContentSettingImageModel> content_setting_image_model(
+ ContentSettingSimpleImageModel::CreateForContentTypeForTesting(
+ CONTENT_SETTINGS_TYPE_GEOLOCATION));
+ BrowserWindowController* controller = [BrowserWindowController
+ browserWindowControllerForWindow:browser()
+ ->window()
+ ->GetNativeWindow()];
+
+ content_setting_decoration_.reset(new ContentSettingDecoration(
+ std::move(content_setting_image_model), [controller locationBarBridge],
+ browser()->profile()));
+ }
+
+ // Returns the content settings bubble window anchored to
+ // |content_setting_decoration_|.
+ NSWindow* GetBubbleWindow() const {
+ return content_setting_decoration_->bubbleWindow_.get();
+ }
+
+ // Simulates a mouse press on the decoration.
+ void PressDecoration() {
+ content_setting_decoration_->OnMousePressed(NSZeroRect, NSZeroPoint);
+ }
+
+ private:
+ std::unique_ptr<ContentSettingDecoration> content_setting_decoration_;
+
+ DISALLOW_COPY_AND_ASSIGN(ContentSettingDecorationTest);
+};
+
+// Tests to check if pressing the decoration will open/close the content
+// settings bubble.
+IN_PROC_BROWSER_TEST_F(ContentSettingDecorationTest, DecorationPress) {
+ // Bubble should appear.
+ PressDecoration();
+ EXPECT_TRUE(GetBubbleWindow());
+
+ // Bubble should be closed.
+ PressDecoration();
+ EXPECT_FALSE(GetBubbleWindow());
+
+ // Bubble should reappear.
+ PressDecoration();
+ EXPECT_TRUE(GetBubbleWindow());
+}
« no previous file with comments | « chrome/browser/ui/cocoa/location_bar/content_setting_decoration.h ('k') | chrome/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698