forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmedia_notification_controller_impl_unittest.cc
726 lines (551 loc) · 22.8 KB
/
media_notification_controller_impl_unittest.cc
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
// Copyright 2018 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.
#include "ash/media/media_notification_controller_impl.h"
#include <memory>
#include "ash/media/media_notification_constants.h"
#include "ash/public/cpp/ash_features.h"
#include "ash/public/cpp/notification_utils.h"
#include "ash/session/session_controller_impl.h"
#include "ash/shell.h"
#include "ash/test/ash_test_base.h"
#include "base/macros.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/test_mock_time_task_runner.h"
#include "base/unguessable_token.h"
#include "components/media_message_center/media_notification_item.h"
#include "components/media_message_center/media_notification_util.h"
#include "services/media_session/public/mojom/audio_focus.mojom.h"
#include "ui/message_center/message_center.h"
namespace ash {
namespace {
media_session::mojom::MediaSessionInfoPtr BuildMediaSessionInfo(
bool is_controllable) {
media_session::mojom::MediaSessionInfoPtr session_info(
media_session::mojom::MediaSessionInfo::New());
session_info->is_controllable = is_controllable;
return session_info;
}
media_session::mojom::AudioFocusRequestStatePtr GetRequestStateWithId(
const base::UnguessableToken& id) {
media_session::mojom::AudioFocusRequestStatePtr session(
media_session::mojom::AudioFocusRequestState::New());
session->request_id = id;
session->session_info = BuildMediaSessionInfo(true);
return session;
}
} // namespace
class MediaNotificationControllerImplTest : public AshTestBase {
public:
MediaNotificationControllerImplTest()
: task_runner_(new base::TestMockTimeTaskRunner(
base::TestMockTimeTaskRunner::Type::kStandalone)) {}
~MediaNotificationControllerImplTest() override = default;
// AshTestBase
void SetUp() override {
scoped_feature_list_.InitAndEnableFeature(
features::kMediaSessionNotification);
AshTestBase::SetUp();
Shell::Get()->media_notification_controller()->set_task_runner_for_testing(
task_runner_);
}
void ExpectNotificationCount(unsigned count) {
message_center::MessageCenter* message_center =
message_center::MessageCenter::Get();
EXPECT_EQ(count, message_center->GetVisibleNotifications().size());
// Media notifications should never be shown as a popup so we always check
// this is empty.
EXPECT_TRUE(message_center->GetPopupNotifications().empty());
}
media_session::MediaMetadata BuildMediaMetadata() {
media_session::MediaMetadata metadata;
metadata.title = base::ASCIIToUTF16("title");
metadata.artist = base::ASCIIToUTF16("artist");
return metadata;
}
void ExpectHistogramCountRecorded(int count, int size) {
histogram_tester_.ExpectBucketCount(
media_message_center::kCountHistogramName, count, size);
}
void ExpectHistogramSourceRecorded(
media_message_center::MediaNotificationItem::Source source) {
histogram_tester_.ExpectUniqueSample(
media_message_center::MediaNotificationItem::kSourceHistogramName,
static_cast<base::HistogramBase::Sample>(source), 1);
}
void SimulateSessionLock(bool locked) {
SessionInfo info;
info.state = locked ? session_manager::SessionState::LOCKED
: session_manager::SessionState::ACTIVE;
Shell::Get()->session_controller()->SetSessionInfo(info);
}
void SimulateFreezeTimerExpired() {
task_runner_->FastForwardBy(base::TimeDelta::FromMilliseconds(2500));
}
private:
scoped_refptr<base::TestMockTimeTaskRunner> task_runner_;
base::test::ScopedFeatureList scoped_feature_list_;
base::HistogramTester histogram_tester_;
DISALLOW_COPY_AND_ASSIGN(MediaNotificationControllerImplTest);
};
// Test toggling the notification multiple times with the same ID. Since the
// notification is keyed by ID we should only ever show one.
TEST_F(MediaNotificationControllerImplTest, OnFocusGainedLost_SameId) {
base::UnguessableToken id = base::UnguessableToken::Create();
ExpectNotificationCount(0);
Shell::Get()->media_notification_controller()->OnFocusGained(
GetRequestStateWithId(id));
Shell::Get()
->media_notification_controller()
->GetItem(id.ToString())
->MediaSessionMetadataChanged(BuildMediaMetadata());
ExpectNotificationCount(1);
ExpectHistogramCountRecorded(1, 1);
Shell::Get()->media_notification_controller()->OnFocusGained(
GetRequestStateWithId(id));
ExpectNotificationCount(1);
ExpectHistogramCountRecorded(1, 1);
Shell::Get()->media_notification_controller()->OnFocusLost(
GetRequestStateWithId(id));
SimulateFreezeTimerExpired();
ExpectNotificationCount(0);
}
// Test toggling the notification multiple times with different IDs. This should
// show one notification per ID.
TEST_F(MediaNotificationControllerImplTest, OnFocusGainedLost_MultipleIds) {
base::UnguessableToken id1 = base::UnguessableToken::Create();
base::UnguessableToken id2 = base::UnguessableToken::Create();
ExpectNotificationCount(0);
Shell::Get()->media_notification_controller()->OnFocusGained(
GetRequestStateWithId(id1));
Shell::Get()
->media_notification_controller()
->GetItem(id1.ToString())
->MediaSessionMetadataChanged(BuildMediaMetadata());
ExpectNotificationCount(1);
ExpectHistogramCountRecorded(1, 1);
Shell::Get()->media_notification_controller()->OnFocusGained(
GetRequestStateWithId(id2));
Shell::Get()
->media_notification_controller()
->GetItem(id2.ToString())
->MediaSessionMetadataChanged(BuildMediaMetadata());
ExpectNotificationCount(2);
ExpectHistogramCountRecorded(2, 1);
Shell::Get()->media_notification_controller()->OnFocusLost(
GetRequestStateWithId(id1));
SimulateFreezeTimerExpired();
ExpectNotificationCount(1);
ExpectHistogramCountRecorded(1, 1);
}
// Test that a notification is hidden when it becomes uncontrollable. We still
// keep the media_message_center::MediaNotificationItem around in case it
// becomes controllable again.
TEST_F(MediaNotificationControllerImplTest,
OnFocusGained_ControllableBecomesUncontrollable) {
base::UnguessableToken id = base::UnguessableToken::Create();
ExpectNotificationCount(0);
Shell::Get()->media_notification_controller()->OnFocusGained(
GetRequestStateWithId(id));
Shell::Get()
->media_notification_controller()
->GetItem(id.ToString())
->MediaSessionMetadataChanged(BuildMediaMetadata());
ExpectNotificationCount(1);
ExpectHistogramCountRecorded(1, 1);
Shell::Get()
->media_notification_controller()
->GetItem(id.ToString())
->MediaSessionInfoChanged(BuildMediaSessionInfo(false));
ExpectNotificationCount(0);
}
// Test that a notification is shown when it becomes controllable.
TEST_F(MediaNotificationControllerImplTest,
OnFocusGained_NotControllableBecomesControllable) {
base::UnguessableToken id = base::UnguessableToken::Create();
ExpectNotificationCount(0);
media_session::mojom::AudioFocusRequestStatePtr state =
GetRequestStateWithId(id);
state->session_info->is_controllable = false;
Shell::Get()->media_notification_controller()->OnFocusGained(
std::move(state));
Shell::Get()
->media_notification_controller()
->GetItem(id.ToString())
->MediaSessionMetadataChanged(BuildMediaMetadata());
ExpectNotificationCount(0);
Shell::Get()
->media_notification_controller()
->GetItem(id.ToString())
->MediaSessionInfoChanged(BuildMediaSessionInfo(true));
ExpectNotificationCount(1);
ExpectHistogramCountRecorded(1, 1);
}
// Test hiding a notification with an invalid ID.
TEST_F(MediaNotificationControllerImplTest, OnFocusLost_Noop) {
ExpectNotificationCount(0);
Shell::Get()->media_notification_controller()->OnFocusLost(
GetRequestStateWithId(base::UnguessableToken::Create()));
ExpectNotificationCount(0);
}
// Test that media notifications have the correct custom view type.
TEST_F(MediaNotificationControllerImplTest, NotificationHasCustomViewType) {
ExpectNotificationCount(0);
base::UnguessableToken id = base::UnguessableToken::Create();
Shell::Get()->media_notification_controller()->OnFocusGained(
GetRequestStateWithId(id));
Shell::Get()
->media_notification_controller()
->GetItem(id.ToString())
->MediaSessionMetadataChanged(BuildMediaMetadata());
ExpectNotificationCount(1);
ExpectHistogramCountRecorded(1, 1);
message_center::Notification* notification =
message_center::MessageCenter::Get()->FindVisibleNotificationById(
id.ToString());
EXPECT_TRUE(notification);
EXPECT_EQ(kMediaSessionNotificationCustomViewType,
notification->custom_view_type());
}
// Test that if we recieve a null media session info that we hide the
// notification.
TEST_F(MediaNotificationControllerImplTest, HandleNullMediaSessionInfo) {
ExpectNotificationCount(0);
base::UnguessableToken id = base::UnguessableToken::Create();
Shell::Get()->media_notification_controller()->OnFocusGained(
GetRequestStateWithId(id));
Shell::Get()
->media_notification_controller()
->GetItem(id.ToString())
->MediaSessionMetadataChanged(BuildMediaMetadata());
ExpectNotificationCount(1);
ExpectHistogramCountRecorded(1, 1);
Shell::Get()
->media_notification_controller()
->GetItem(id.ToString())
->MediaSessionInfoChanged(nullptr);
ExpectNotificationCount(0);
}
TEST_F(MediaNotificationControllerImplTest, MediaMetadata_NoTitle) {
base::UnguessableToken id = base::UnguessableToken::Create();
ExpectNotificationCount(0);
Shell::Get()->media_notification_controller()->OnFocusGained(
GetRequestStateWithId(id));
media_session::MediaMetadata metadata;
metadata.artist = base::ASCIIToUTF16("artist");
Shell::Get()
->media_notification_controller()
->GetItem(id.ToString())
->MediaSessionMetadataChanged(metadata);
ExpectNotificationCount(0);
}
TEST_F(MediaNotificationControllerImplTest, MediaMetadataUpdated_MissingInfo) {
base::UnguessableToken id = base::UnguessableToken::Create();
ExpectNotificationCount(0);
Shell::Get()->media_notification_controller()->OnFocusGained(
GetRequestStateWithId(id));
Shell::Get()
->media_notification_controller()
->GetItem(id.ToString())
->MediaSessionMetadataChanged(BuildMediaMetadata());
ExpectNotificationCount(1);
ExpectHistogramCountRecorded(1, 1);
Shell::Get()
->media_notification_controller()
->GetItem(id.ToString())
->MediaSessionMetadataChanged(media_session::MediaMetadata());
ExpectNotificationCount(0);
}
TEST_F(MediaNotificationControllerImplTest, RecordHistogramSource_Unknown) {
base::UnguessableToken id = base::UnguessableToken::Create();
ExpectNotificationCount(0);
Shell::Get()->media_notification_controller()->OnFocusGained(
GetRequestStateWithId(id));
Shell::Get()
->media_notification_controller()
->GetItem(id.ToString())
->MediaSessionMetadataChanged(BuildMediaMetadata());
ExpectNotificationCount(1);
ExpectHistogramSourceRecorded(
media_message_center::MediaNotificationItem::Source::kUnknown);
}
TEST_F(MediaNotificationControllerImplTest, RecordHistogramSource_Web) {
base::UnguessableToken id = base::UnguessableToken::Create();
ExpectNotificationCount(0);
media_session::mojom::AudioFocusRequestStatePtr request =
GetRequestStateWithId(id);
request->source_name = "web";
Shell::Get()->media_notification_controller()->OnFocusGained(
std::move(request));
Shell::Get()
->media_notification_controller()
->GetItem(id.ToString())
->MediaSessionMetadataChanged(BuildMediaMetadata());
ExpectNotificationCount(1);
ExpectHistogramSourceRecorded(
media_message_center::MediaNotificationItem::Source::kWeb);
}
TEST_F(MediaNotificationControllerImplTest, RecordHistogramSource_Assistant) {
base::UnguessableToken id = base::UnguessableToken::Create();
ExpectNotificationCount(0);
media_session::mojom::AudioFocusRequestStatePtr request =
GetRequestStateWithId(id);
request->source_name = "assistant";
Shell::Get()->media_notification_controller()->OnFocusGained(
std::move(request));
Shell::Get()
->media_notification_controller()
->GetItem(id.ToString())
->MediaSessionMetadataChanged(BuildMediaMetadata());
ExpectNotificationCount(1);
ExpectHistogramSourceRecorded(
media_message_center::MediaNotificationItem::Source::kAssistant);
}
TEST_F(MediaNotificationControllerImplTest, RecordHistogramSource_Arc) {
base::UnguessableToken id = base::UnguessableToken::Create();
ExpectNotificationCount(0);
media_session::mojom::AudioFocusRequestStatePtr request =
GetRequestStateWithId(id);
request->source_name = "arc";
Shell::Get()->media_notification_controller()->OnFocusGained(
std::move(request));
Shell::Get()
->media_notification_controller()
->GetItem(id.ToString())
->MediaSessionMetadataChanged(BuildMediaMetadata());
ExpectNotificationCount(1);
ExpectHistogramSourceRecorded(
media_message_center::MediaNotificationItem::Source::kArc);
}
// Test that locking the screen will hide the media notifications. Unlocking the
// screen should re-show the notifications.
TEST_F(MediaNotificationControllerImplTest, HideWhenScreenLocked) {
message_center::MessageCenter* message_center =
message_center::MessageCenter::Get();
base::UnguessableToken id = base::UnguessableToken::Create();
ExpectNotificationCount(0);
Shell::Get()->media_notification_controller()->OnFocusGained(
GetRequestStateWithId(id));
Shell::Get()
->media_notification_controller()
->GetItem(id.ToString())
->MediaSessionMetadataChanged(BuildMediaMetadata());
ExpectNotificationCount(1);
// Show a non-media notification that should still be displayed.
message_center->AddNotification(
CreateSystemNotification("test", base::string16(), base::string16(),
"test", base::BindRepeating([]() {})));
EXPECT_EQ(2u, message_center->GetVisibleNotifications().size());
// Lock the screen and only the non-media notification should be visible.
SimulateSessionLock(true);
{
auto notifications = message_center->GetVisibleNotifications();
EXPECT_EQ(1u, notifications.size());
EXPECT_EQ("test", (*notifications.begin())->id());
}
// Unlock the screen and both notifications should be visible again.
SimulateSessionLock(false);
EXPECT_EQ(2u, message_center->GetVisibleNotifications().size());
}
// Test that when we lose focus we freeze the notification until the timer
// is fired and then remove it.
TEST_F(MediaNotificationControllerImplTest, OnFocusLostFreezeUntilTimerFired) {
base::UnguessableToken id = base::UnguessableToken::Create();
ExpectNotificationCount(0);
Shell::Get()->media_notification_controller()->OnFocusGained(
GetRequestStateWithId(id));
Shell::Get()
->media_notification_controller()
->GetItem(id.ToString())
->MediaSessionMetadataChanged(BuildMediaMetadata());
ExpectNotificationCount(1);
EXPECT_FALSE(Shell::Get()
->media_notification_controller()
->GetItem(id.ToString())
->frozen());
Shell::Get()->media_notification_controller()->OnFocusLost(
GetRequestStateWithId(id));
ExpectNotificationCount(1);
EXPECT_TRUE(Shell::Get()
->media_notification_controller()
->GetItem(id.ToString())
->frozen());
SimulateFreezeTimerExpired();
ExpectNotificationCount(0);
}
// Test that when we lose focus we freeze the notification and then we see
// the session resume we keep the notification and unfreeze it.
TEST_F(MediaNotificationControllerImplTest, OnFocusLostFreezeAndResumeSameId) {
base::UnguessableToken id = base::UnguessableToken::Create();
ExpectNotificationCount(0);
Shell::Get()->media_notification_controller()->OnFocusGained(
GetRequestStateWithId(id));
Shell::Get()
->media_notification_controller()
->GetItem(id.ToString())
->MediaSessionMetadataChanged(BuildMediaMetadata());
ExpectNotificationCount(1);
EXPECT_FALSE(Shell::Get()
->media_notification_controller()
->GetItem(id.ToString())
->frozen());
Shell::Get()->media_notification_controller()->OnFocusLost(
GetRequestStateWithId(id));
ExpectNotificationCount(1);
EXPECT_TRUE(Shell::Get()
->media_notification_controller()
->GetItem(id.ToString())
->frozen());
Shell::Get()->media_notification_controller()->OnFocusGained(
GetRequestStateWithId(id));
Shell::Get()
->media_notification_controller()
->GetItem(id.ToString())
->MediaSessionMetadataChanged(BuildMediaMetadata());
// The session comes back and is controllable so we should unfreeze the
// notification.
ExpectNotificationCount(1);
EXPECT_FALSE(Shell::Get()
->media_notification_controller()
->GetItem(id.ToString())
->frozen());
}
// Test that when we lose focus we freeze the notification and then we see
// the session resume but it is missing metadata we hide the notification.
TEST_F(MediaNotificationControllerImplTest,
OnFocusLostFreezeAndResumeSameId_MissingMetadata) {
base::UnguessableToken id = base::UnguessableToken::Create();
ExpectNotificationCount(0);
Shell::Get()->media_notification_controller()->OnFocusGained(
GetRequestStateWithId(id));
Shell::Get()
->media_notification_controller()
->GetItem(id.ToString())
->MediaSessionMetadataChanged(BuildMediaMetadata());
ExpectNotificationCount(1);
EXPECT_FALSE(Shell::Get()
->media_notification_controller()
->GetItem(id.ToString())
->frozen());
Shell::Get()->media_notification_controller()->OnFocusLost(
GetRequestStateWithId(id));
ExpectNotificationCount(1);
EXPECT_TRUE(Shell::Get()
->media_notification_controller()
->GetItem(id.ToString())
->frozen());
Shell::Get()->media_notification_controller()->OnFocusGained(
GetRequestStateWithId(id));
Shell::Get()
->media_notification_controller()
->GetItem(id.ToString())
->MediaSessionMetadataChanged(media_session::MediaMetadata());
// The session has come back but the metadata is missing data so we should
// keep the notification frozen.
ExpectNotificationCount(1);
EXPECT_TRUE(Shell::Get()
->media_notification_controller()
->GetItem(id.ToString())
->frozen());
// After the timer has been fired we should hide the notification but still
// have the controller.
SimulateFreezeTimerExpired();
ExpectNotificationCount(0);
EXPECT_TRUE(Shell::Get()->media_notification_controller()->HasItemForTesting(
id.ToString()));
}
// Test that when we lose focus we freeze the notification and then we see
// the session resume but it is not controllable we hide the notification.
TEST_F(MediaNotificationControllerImplTest,
OnFocusLostFreezeAndResumeSameId_NotControllable) {
base::UnguessableToken id = base::UnguessableToken::Create();
ExpectNotificationCount(0);
Shell::Get()->media_notification_controller()->OnFocusGained(
GetRequestStateWithId(id));
Shell::Get()
->media_notification_controller()
->GetItem(id.ToString())
->MediaSessionMetadataChanged(BuildMediaMetadata());
ExpectNotificationCount(1);
EXPECT_FALSE(Shell::Get()
->media_notification_controller()
->GetItem(id.ToString())
->frozen());
Shell::Get()->media_notification_controller()->OnFocusLost(
GetRequestStateWithId(id));
ExpectNotificationCount(1);
EXPECT_TRUE(Shell::Get()
->media_notification_controller()
->GetItem(id.ToString())
->frozen());
media_session::mojom::AudioFocusRequestStatePtr state =
GetRequestStateWithId(id);
state->session_info->is_controllable = false;
Shell::Get()->media_notification_controller()->OnFocusGained(
std::move(state));
Shell::Get()
->media_notification_controller()
->GetItem(id.ToString())
->MediaSessionMetadataChanged(BuildMediaMetadata());
// The session has come back but the metadata is not controllable so we should
// keep the notification frozen.
ExpectNotificationCount(1);
EXPECT_TRUE(Shell::Get()
->media_notification_controller()
->GetItem(id.ToString())
->frozen());
// After the timer has been fired we should hide the notification but still
// have the controller.
SimulateFreezeTimerExpired();
ExpectNotificationCount(0);
EXPECT_TRUE(Shell::Get()->media_notification_controller()->HasItemForTesting(
id.ToString()));
}
// Test that when we lose focus we freeze the notification and we see a new
// session then that does not unfreeze the first notification.
TEST_F(MediaNotificationControllerImplTest,
OnFocusLostFreezeAndDoNotResumeNewId) {
base::UnguessableToken id1 = base::UnguessableToken::Create();
base::UnguessableToken id2 = base::UnguessableToken::Create();
ExpectNotificationCount(0);
Shell::Get()->media_notification_controller()->OnFocusGained(
GetRequestStateWithId(id1));
Shell::Get()
->media_notification_controller()
->GetItem(id1.ToString())
->MediaSessionMetadataChanged(BuildMediaMetadata());
ExpectNotificationCount(1);
EXPECT_FALSE(Shell::Get()
->media_notification_controller()
->GetItem(id1.ToString())
->frozen());
Shell::Get()->media_notification_controller()->OnFocusLost(
GetRequestStateWithId(id1));
ExpectNotificationCount(1);
EXPECT_TRUE(Shell::Get()
->media_notification_controller()
->GetItem(id1.ToString())
->frozen());
Shell::Get()->media_notification_controller()->OnFocusGained(
GetRequestStateWithId(id2));
Shell::Get()
->media_notification_controller()
->GetItem(id2.ToString())
->MediaSessionMetadataChanged(BuildMediaMetadata());
ExpectNotificationCount(2);
EXPECT_TRUE(Shell::Get()
->media_notification_controller()
->GetItem(id1.ToString())
->frozen());
EXPECT_FALSE(Shell::Get()
->media_notification_controller()
->GetItem(id2.ToString())
->frozen());
SimulateFreezeTimerExpired();
ExpectNotificationCount(1);
EXPECT_FALSE(Shell::Get()->media_notification_controller()->HasItemForTesting(
id1.ToString()));
}
} // namespace ash