OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // This file tests the chrome.alarms extension API. | 5 // This file tests the chrome.alarms extension API. |
6 | 6 |
7 #include "base/test/simple_test_clock.h" | 7 #include "base/test/simple_test_clock.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "content/public/browser/web_contents.h" | 9 #include "content/public/browser/web_contents.h" |
10 #include "content/public/test/mock_render_process_host.h" | 10 #include "content/public/test/mock_render_process_host.h" |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 // Create an alarm with delay below the minimum accepted value. | 290 // Create an alarm with delay below the minimum accepted value. |
291 CreateAlarm("[\"negative\", {\"delayInMinutes\": -0.2}]"); | 291 CreateAlarm("[\"negative\", {\"delayInMinutes\": -0.2}]"); |
292 IPC::TestSink& sink = | 292 IPC::TestSink& sink = |
293 static_cast<content::MockRenderProcessHost*>( | 293 static_cast<content::MockRenderProcessHost*>( |
294 contents()->GetRenderViewHost()->GetProcess())->sink(); | 294 contents()->GetRenderViewHost()->GetProcess())->sink(); |
295 const IPC::Message* warning = | 295 const IPC::Message* warning = |
296 sink.GetUniqueMessageMatching(ExtensionMsg_AddMessageToConsole::ID); | 296 sink.GetUniqueMessageMatching(ExtensionMsg_AddMessageToConsole::ID); |
297 ASSERT_TRUE(warning); | 297 ASSERT_TRUE(warning); |
298 ExtensionMsg_AddMessageToConsole::Param params; | 298 ExtensionMsg_AddMessageToConsole::Param params; |
299 ExtensionMsg_AddMessageToConsole::Read(warning, ¶ms); | 299 ExtensionMsg_AddMessageToConsole::Read(warning, ¶ms); |
300 content::ConsoleMessageLevel level = get<0>(params); | 300 content::ConsoleMessageLevel level = base::get<0>(params); |
301 std::string message = get<1>(params); | 301 std::string message = base::get<1>(params); |
302 EXPECT_EQ(content::CONSOLE_MESSAGE_LEVEL_WARNING, level); | 302 EXPECT_EQ(content::CONSOLE_MESSAGE_LEVEL_WARNING, level); |
303 EXPECT_THAT(message, testing::HasSubstr("delay is less than minimum of 1")); | 303 EXPECT_THAT(message, testing::HasSubstr("delay is less than minimum of 1")); |
304 } | 304 } |
305 | 305 |
306 TEST_F(ExtensionAlarmsTest, Get) { | 306 TEST_F(ExtensionAlarmsTest, Get) { |
307 test_clock_->SetNow(base::Time::FromDoubleT(4)); | 307 test_clock_->SetNow(base::Time::FromDoubleT(4)); |
308 | 308 |
309 // Create 2 alarms, and make sure we can query them. | 309 // Create 2 alarms, and make sure we can query them. |
310 CreateAlarms(2); | 310 CreateAlarms(2); |
311 | 311 |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
677 | 677 |
678 // The next poll should be the first poll that hasn't happened and is in-line | 678 // The next poll should be the first poll that hasn't happened and is in-line |
679 // with the original scheduling. | 679 // with the original scheduling. |
680 // Last poll was at 380 seconds; next poll should be at 480 seconds. | 680 // Last poll was at 380 seconds; next poll should be at 480 seconds. |
681 EXPECT_DOUBLE_EQ((alarm_manager_->last_poll_time_ + | 681 EXPECT_DOUBLE_EQ((alarm_manager_->last_poll_time_ + |
682 base::TimeDelta::FromSeconds(100)).ToJsTime(), | 682 base::TimeDelta::FromSeconds(100)).ToJsTime(), |
683 alarm_manager_->next_poll_time_.ToJsTime()); | 683 alarm_manager_->next_poll_time_.ToJsTime()); |
684 } | 684 } |
685 | 685 |
686 } // namespace extensions | 686 } // namespace extensions |
OLD | NEW |