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

Side by Side Diff: chrome/browser/notifications/notification_interactive_uitest_mac.mm

Issue 2729613006: When navigation focuses a web contents, also activate its window. (Closed)
Patch Set: Created 3 years, 9 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2017 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.
4
5 #import <AppKit/AppKit.h>
6
7 #include "base/run_loop.h"
8 #include "chrome/browser/notifications/notification_test_util.h"
9 #include "chrome/browser/ui/browser.h"
10 #include "chrome/browser/ui/browser_window.h"
11 #include "chrome/test/base/interactive_test_utils.h"
12 #include "chrome/test/base/ui_test_utils.h"
13 #import "ui/base/test/windowed_nsnotification_observer.h"
14 #include "ui/message_center/message_center.h"
15
16 // Verify that Chrome becomes the active app when clicking a notification opens
17 // a new window.
18 IN_PROC_BROWSER_TEST_F(NotificationsTest, TestPopupShouldActivateApp) {
19 EXPECT_TRUE(embedded_test_server()->Start());
20
21 // Creates a simple notification.
22 AllowAllOrigins();
23 ui_test_utils::NavigateToURL(browser(), GetTestPageURL());
24
25 EXPECT_TRUE(ui_test_utils::ShowAndFocusNativeWindow(
26 browser()->window()->GetNativeWindow()));
27
28 {
29 base::scoped_nsobject<WindowedNSNotificationObserver> observer(
30 [[WindowedNSNotificationObserver alloc]
31 initForNotification:NSApplicationDidResignActiveNotification
32 object:NSApp]);
33 [NSApp hide:nil];
34 [observer wait];
35 }
36 EXPECT_FALSE([NSApp isActive]);
37
38 std::string result = CreateNotification(
39 browser(), true, "no_such_file.png", "Popup", "", "",
40 "window.open('', '', 'width=100,height=100').focus();");
41 EXPECT_NE("-1", result);
42
43 auto message_center = message_center::MessageCenter::Get();
44 message_center::Notification* notification =
45 *message_center->GetVisibleNotifications().begin();
46 message_center->ClickOnNotification(notification->id());
47
48 {
49 base::scoped_nsobject<WindowedNSNotificationObserver> observer(
50 [[WindowedNSNotificationObserver alloc]
51 initForNotification:NSApplicationDidBecomeActiveNotification
52 object:NSApp]);
53 [NSApp hide:nil];
54 [observer wait];
55 }
56 EXPECT_TRUE([NSApp isActive]);
57 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698