1 // Copyright 2015 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/ui/webui/media_router/media_cast_mode.h"
6 #include "testing/gtest/include/gtest/gtest.h"
8 namespace media_router
{
10 TEST(MediaCastModeTest
, PreferredCastMode
) {
11 CastModeSet cast_modes
;
13 EXPECT_EQ(MediaCastMode::DEFAULT
, GetPreferredCastMode(cast_modes
));
15 cast_modes
.insert(MediaCastMode::SOUND_OPTIMIZED_TAB_MIRROR
);
16 EXPECT_EQ(MediaCastMode::SOUND_OPTIMIZED_TAB_MIRROR
,
17 GetPreferredCastMode(cast_modes
));
19 cast_modes
.insert(MediaCastMode::DESKTOP_OR_WINDOW_MIRROR
);
20 EXPECT_EQ(MediaCastMode::DESKTOP_OR_WINDOW_MIRROR
,
21 GetPreferredCastMode(cast_modes
));
23 cast_modes
.insert(MediaCastMode::TAB_MIRROR
);
24 EXPECT_EQ(MediaCastMode::TAB_MIRROR
,
25 GetPreferredCastMode(cast_modes
));
27 cast_modes
.insert(MediaCastMode::DEFAULT
);
28 EXPECT_EQ(MediaCastMode::DEFAULT
,
29 GetPreferredCastMode(cast_modes
));
31 cast_modes
.erase(MediaCastMode::TAB_MIRROR
);
32 EXPECT_EQ(MediaCastMode::DEFAULT
,
33 GetPreferredCastMode(cast_modes
));
35 cast_modes
.erase(MediaCastMode::DESKTOP_OR_WINDOW_MIRROR
);
36 EXPECT_EQ(MediaCastMode::DEFAULT
,
37 GetPreferredCastMode(cast_modes
));
39 cast_modes
.erase(MediaCastMode::SOUND_OPTIMIZED_TAB_MIRROR
);
40 EXPECT_EQ(MediaCastMode::DEFAULT
,
41 GetPreferredCastMode(cast_modes
));
44 TEST(MediaCastModeTest
, MediaCastModeToTitleAndDescription
) {
45 for (int cast_mode
= MediaCastMode::DEFAULT
;
46 cast_mode
< MediaCastMode::NUM_CAST_MODES
; cast_mode
++) {
47 EXPECT_TRUE(!MediaCastModeToTitle(
48 static_cast<MediaCastMode
>(cast_mode
), "youtube.com").empty());
49 EXPECT_TRUE(!MediaCastModeToDescription(
50 static_cast<MediaCastMode
>(cast_mode
), "youtube.com").empty());
54 TEST(MediaCastModeTest
, IsValidCastModeNum
) {
55 for (int cast_mode
= MediaCastMode::DEFAULT
;
56 cast_mode
< MediaCastMode::NUM_CAST_MODES
; cast_mode
++) {
57 EXPECT_TRUE(IsValidCastModeNum(cast_mode
));
59 EXPECT_FALSE(IsValidCastModeNum(MediaCastMode::NUM_CAST_MODES
));
60 EXPECT_FALSE(IsValidCastModeNum(-1));
63 } // namespace media_router