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

Side by Side Diff: chrome/test/chromedriver/net/timeout_unittest.cc

Issue 1669453002: [chromedriver] Apply page load timeout to slow cross-process navigations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: pure virtual Created 4 years, 8 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
« no previous file with comments | « chrome/test/chromedriver/net/timeout.cc ('k') | chrome/test/chromedriver/performance_logger.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2016 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 #include "base/logging.h"
6 #include "chrome/test/chromedriver/net/timeout.h"
7 #include "testing/gtest/include/gtest/gtest.h"
8
9 using base::TimeDelta;
10
11 TEST(TimeoutTest, Basics) {
12 Timeout timeout;
13 EXPECT_FALSE(timeout.is_set());
14 EXPECT_FALSE(timeout.IsExpired());
15 EXPECT_EQ(TimeDelta::Max(), timeout.GetDuration());
16 EXPECT_EQ(TimeDelta::Max(), timeout.GetRemainingTime());
17
18 timeout.SetDuration(TimeDelta());
19 EXPECT_TRUE(timeout.is_set());
20 EXPECT_TRUE(timeout.IsExpired());
21 EXPECT_EQ(TimeDelta(), timeout.GetDuration());
22 EXPECT_GE(TimeDelta(), timeout.GetRemainingTime());
23 }
24
25 TEST(TimeoutTest, SetDuration) {
26 Timeout timeout(TimeDelta::FromSeconds(1));
27
28 // It's ok to set the same duration again, since nothing changes.
29 timeout.SetDuration(TimeDelta::FromSeconds(1));
30
31 #if DCHECK_IS_ON() && GTEST_HAS_DEATH_TEST && !defined(OS_ANDROID)
32 EXPECT_DEATH(timeout.SetDuration(TimeDelta::FromMinutes(30)), "");
33 #endif // DCHECK_IS_ON() && GTEST_HAS_DEATH_TEST && !defined(OS_ANDROID)
34 }
35
36 TEST(TimeoutTest, Derive) {
37 Timeout timeout(TimeDelta::FromMinutes(5));
38 EXPECT_TRUE(timeout.is_set());
39 EXPECT_FALSE(timeout.IsExpired());
40 EXPECT_EQ(TimeDelta::FromMinutes(5), timeout.GetDuration());
41 EXPECT_GE(TimeDelta::FromMinutes(5), timeout.GetRemainingTime());
42
43 Timeout small = Timeout(TimeDelta::FromSeconds(10), &timeout);
44 EXPECT_TRUE(small.is_set());
45 EXPECT_FALSE(small.IsExpired());
46 EXPECT_EQ(TimeDelta::FromSeconds(10), small.GetDuration());
47
48 Timeout large = Timeout(TimeDelta::FromMinutes(30), &timeout);
49 EXPECT_TRUE(large.is_set());
50 EXPECT_FALSE(large.IsExpired());
51 EXPECT_GE(timeout.GetDuration(), large.GetDuration());
52 }
53
54 TEST(TimeoutTest, DeriveExpired) {
55 Timeout timeout((TimeDelta()));
56 EXPECT_TRUE(timeout.is_set());
57 EXPECT_TRUE(timeout.IsExpired());
58
59 Timeout derived = Timeout(TimeDelta::FromSeconds(10), &timeout);
60 EXPECT_TRUE(derived.is_set());
61 EXPECT_TRUE(derived.IsExpired());
62 EXPECT_GE(TimeDelta(), derived.GetDuration());
63 }
OLDNEW
« no previous file with comments | « chrome/test/chromedriver/net/timeout.cc ('k') | chrome/test/chromedriver/performance_logger.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698