cygprofile: increase timeouts to allow showing web contents
[chromium-blink-merge.git] / chrome / browser / ui / webui / media_router / media_cast_mode_unittest.cc
blob62ba540bcb19884d92f4080137c4ee885ae7e4d1
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"
7 #include "testing/gmock/include/gmock/gmock.h"
8 #include "testing/gtest/include/gtest/gtest.h"
10 using testing::Not;
11 using testing::HasSubstr;
13 namespace media_router {
15 TEST(MediaCastModeTest, PreferredCastMode) {
16 CastModeSet cast_modes;
18 EXPECT_EQ(MediaCastMode::DEFAULT, GetPreferredCastMode(cast_modes));
20 cast_modes.insert(MediaCastMode::DESKTOP_MIRROR);
21 EXPECT_EQ(MediaCastMode::DESKTOP_MIRROR,
22 GetPreferredCastMode(cast_modes));
24 cast_modes.insert(MediaCastMode::TAB_MIRROR);
25 EXPECT_EQ(MediaCastMode::TAB_MIRROR,
26 GetPreferredCastMode(cast_modes));
28 cast_modes.insert(MediaCastMode::DEFAULT);
29 EXPECT_EQ(MediaCastMode::DEFAULT,
30 GetPreferredCastMode(cast_modes));
32 cast_modes.erase(MediaCastMode::TAB_MIRROR);
33 EXPECT_EQ(MediaCastMode::DEFAULT,
34 GetPreferredCastMode(cast_modes));
36 cast_modes.erase(MediaCastMode::DESKTOP_MIRROR);
37 EXPECT_EQ(MediaCastMode::DEFAULT,
38 GetPreferredCastMode(cast_modes));
41 TEST(MediaCastModeTest, MediaCastModeToDescription) {
42 for (int cast_mode = MediaCastMode::DEFAULT;
43 cast_mode < MediaCastMode::NUM_CAST_MODES; cast_mode++) {
44 EXPECT_TRUE(!MediaCastModeToDescription(
45 static_cast<MediaCastMode>(cast_mode), "youtube.com").empty());
49 TEST(MediaCastModeTest, IsValidCastModeNum) {
50 for (int cast_mode = MediaCastMode::DEFAULT;
51 cast_mode < MediaCastMode::NUM_CAST_MODES; cast_mode++) {
52 EXPECT_TRUE(IsValidCastModeNum(cast_mode));
54 EXPECT_FALSE(IsValidCastModeNum(MediaCastMode::NUM_CAST_MODES));
55 EXPECT_FALSE(IsValidCastModeNum(-1));
58 TEST(MediaCastModeTest, ProperlyTruncatesHostnames) {
59 EXPECT_THAT(
60 MediaCastModeToDescription(MediaCastMode::DEFAULT,
61 "www.kurtisawesome.com"),
62 Not(HasSubstr("www")));
63 EXPECT_THAT(
64 MediaCastModeToDescription(MediaCastMode::DEFAULT,
65 "www.kurtisawesome.com"),
66 HasSubstr("kurtisawesome.com"));
68 EXPECT_THAT(
69 MediaCastModeToDescription(MediaCastMode::DEFAULT,
70 "www.kurtisawesome.co.uk"),
71 Not(HasSubstr("www")));
72 EXPECT_THAT(
73 MediaCastModeToDescription(MediaCastMode::DEFAULT,
74 "www.kurtisawesome.co.uk"),
75 HasSubstr("kurtisawesome.co.uk"));
77 EXPECT_THAT(
78 MediaCastModeToDescription(MediaCastMode::DEFAULT,
79 "www.my.kurtisawesome.qld.edu.au"),
80 Not(HasSubstr("www")));
81 EXPECT_THAT(
82 MediaCastModeToDescription(MediaCastMode::DEFAULT,
83 "www.my.kurtisawesome.qld.edu.au"),
84 Not(HasSubstr("www")));
85 EXPECT_THAT(
86 MediaCastModeToDescription(MediaCastMode::DEFAULT,
87 "www.my.kurtisawesome.qld.edu.au"),
88 HasSubstr("kurtisawesome.qld.edu.au"));
90 EXPECT_THAT(
91 MediaCastModeToDescription(MediaCastMode::DEFAULT, "192.168.0.1"),
92 HasSubstr("192.168.0.1"));
95 } // namespace media_router