OLD | NEW |
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium OS 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 #include <base/scoped_ptr.h> | 5 #include <base/scoped_ptr.h> |
6 #include <gtest/gtest.h> | 6 #include <gtest/gtest.h> |
7 | 7 |
8 #include "src/data_plan.h" | 8 #include "src/data_plan.h" |
| 9 #include "src/device_mock.h" |
9 #include "src/json_reader.h" | 10 #include "src/json_reader.h" |
10 #include "src/policy.h" | 11 #include "src/policy.h" |
| 12 #include "src/service_manager_mock.h" |
| 13 #include "src/service_mock.h" |
11 | 14 |
12 namespace cashew { | 15 namespace cashew { |
13 | 16 |
14 // test fixture for DataPlan unit tests | 17 // test fixture for DataPlan unit tests |
15 class DataPlanTest: public ::testing::Test { | 18 class DataPlanTest: public ::testing::Test { |
16 protected: | 19 protected: |
17 DataPlanTest() : policy_(NULL), current_unlimited_plan_(NULL), | 20 DataPlanTest() : policy_(NULL), current_unlimited_plan_(NULL), |
18 current_available_metered_plan_(NULL) {} | 21 current_available_metered_plan_(NULL), plan_one_(NULL), plan_two_(NULL), |
| 22 plan_three_(NULL) {} |
19 | 23 |
20 virtual ~DataPlanTest() { | 24 virtual ~DataPlanTest() { |
21 EXPECT_TRUE(policy_ == NULL); | 25 EXPECT_TRUE(policy_ == NULL); |
22 EXPECT_TRUE(current_unlimited_plan_ == NULL); | 26 EXPECT_TRUE(current_unlimited_plan_ == NULL); |
23 EXPECT_TRUE(current_available_metered_plan_ == NULL); | 27 EXPECT_TRUE(current_available_metered_plan_ == NULL); |
| 28 EXPECT_TRUE(plan_one_ == NULL); |
| 29 EXPECT_TRUE(plan_two_ == NULL); |
| 30 EXPECT_TRUE(plan_three_ == NULL); |
24 } | 31 } |
25 | 32 |
| 33 static const int kBytesPerMegabyte = 1024 * 1024; |
| 34 |
26 virtual void SetUp() { | 35 virtual void SetUp() { |
27 EXPECT_TRUE(policy_ == NULL); | 36 EXPECT_TRUE(policy_ == NULL); |
28 policy_ = Policy::GetPolicy(kTestCarrierName); | 37 policy_ = Policy::GetPolicy(kTestCarrierName); |
29 ASSERT_TRUE(policy_ != NULL); | 38 ASSERT_TRUE(policy_ != NULL); |
30 | 39 |
31 EXPECT_TRUE(current_unlimited_plan_ == NULL); | 40 EXPECT_TRUE(current_unlimited_plan_ == NULL); |
32 DataPlan::Type type = DataPlan::kTypeUnlimited; | 41 DataPlan::Type type = DataPlan::kTypeUnlimited; |
33 base::TimeDelta twelve_hours = base::TimeDelta::FromHours(12); | 42 base::TimeDelta twelve_hours = base::TimeDelta::FromHours(12); |
34 base::Time now = base::Time::Now(); | 43 base::Time now = base::Time::Now(); |
35 base::Time start_time = now - twelve_hours; | 44 base::Time start_time = now - twelve_hours; |
36 base::Time end_time = now + twelve_hours; | 45 base::Time end_time = now + twelve_hours; |
37 Bytes max_bytes = 0; | 46 Bytes max_bytes = 0; |
38 Bytes used_bytes = 5 * 1024 * 1024; | 47 Bytes used_bytes = 5 * kBytesPerMegabyte; |
39 current_unlimited_plan_ = new(std::nothrow) DataPlan( | 48 current_unlimited_plan_ = new(std::nothrow) DataPlan( |
40 "Current Unlimited Plan", type, now, start_time, end_time, max_bytes, | 49 "Current Unlimited Plan", type, now, start_time, end_time, max_bytes, |
41 used_bytes); | 50 used_bytes); |
42 ASSERT_TRUE(current_unlimited_plan_ != NULL); | 51 ASSERT_TRUE(current_unlimited_plan_ != NULL); |
43 | 52 |
44 EXPECT_TRUE(current_available_metered_plan_ == NULL); | 53 EXPECT_TRUE(current_available_metered_plan_ == NULL); |
45 type = DataPlan::kTypeMeteredFree; | 54 type = DataPlan::kTypeMeteredFree; |
46 max_bytes = 100 * 1024 * 1024; | 55 max_bytes = 100 * kBytesPerMegabyte; |
47 current_available_metered_plan_ = new(std::nothrow) DataPlan( | 56 current_available_metered_plan_ = new(std::nothrow) DataPlan( |
48 "Current Available Metered Plan", type, now, start_time, end_time, | 57 "Current Available Metered Plan", type, now, start_time, end_time, |
49 max_bytes, used_bytes); | 58 max_bytes, used_bytes); |
50 ASSERT_TRUE(current_available_metered_plan_ != NULL); | 59 ASSERT_TRUE(current_available_metered_plan_ != NULL); |
| 60 |
| 61 EXPECT_TRUE(plan_one_ == NULL); |
| 62 used_bytes = 0; |
| 63 plan_one_ = new(std::nothrow) DataPlan("Plan One", type, now, start_time, |
| 64 end_time, max_bytes, used_bytes); |
| 65 ASSERT_TRUE(plan_one_ != NULL); |
| 66 |
| 67 EXPECT_TRUE(plan_two_ == NULL); |
| 68 plan_two_ = new(std::nothrow) DataPlan("Plan Two", type, now, start_time, |
| 69 end_time, max_bytes, used_bytes); |
| 70 ASSERT_TRUE(plan_two_ != NULL); |
| 71 |
| 72 EXPECT_TRUE(plan_three_ == NULL); |
| 73 plan_three_ = new(std::nothrow) DataPlan("Plan Three", type, now, |
| 74 start_time, end_time, max_bytes, |
| 75 used_bytes); |
| 76 ASSERT_TRUE(plan_three_ != NULL); |
51 } | 77 } |
52 | 78 |
53 virtual void TearDown() { | 79 virtual void TearDown() { |
| 80 delete plan_three_; |
| 81 plan_three_ = NULL; |
| 82 delete plan_two_; |
| 83 plan_two_ = NULL; |
| 84 delete plan_one_; |
| 85 plan_one_ = NULL; |
54 delete current_available_metered_plan_; | 86 delete current_available_metered_plan_; |
55 current_available_metered_plan_ = NULL; | 87 current_available_metered_plan_ = NULL; |
56 delete current_unlimited_plan_; | 88 delete current_unlimited_plan_; |
57 current_unlimited_plan_ = NULL; | 89 current_unlimited_plan_ = NULL; |
58 delete policy_; | 90 delete policy_; |
59 policy_ = NULL; | 91 policy_ = NULL; |
60 } | 92 } |
61 | 93 |
62 // hardcoded JSON data plan representations | 94 // hardcoded JSON data plan representations |
63 static const char *kMeteredWithUsedBytesJSON; | 95 static const char *kMeteredWithUsedBytesJSON; |
64 static const char *kMeteredWithNoUsedBytesJSON; | 96 static const char *kMeteredWithNoUsedBytesJSON; |
65 static const char *kUnlimitedWithUsedBytesJSON; | 97 static const char *kUnlimitedWithUsedBytesJSON; |
66 static const char *kUnlimitedWithNoUsedBytesJSON; | 98 static const char *kUnlimitedWithNoUsedBytesJSON; |
67 static const char *k32BitSignedOverflowingMaxBytesJSON; | 99 static const char *k32BitSignedOverflowingMaxBytesJSON; |
68 static const char *k32BitUnsignedOverflowingMaxBytesJSON; | 100 static const char *k32BitUnsignedOverflowingMaxBytesJSON; |
69 | 101 |
70 // test carrier for constructing policy | 102 // test carrier for constructing policy |
71 static const char *kTestCarrierName; | 103 static const char *kTestCarrierName; |
72 | 104 |
73 // test policy used by FromDictionaryValue tests | 105 // test policy used by FromDictionaryValue tests |
74 Policy *policy_; | 106 Policy *policy_; |
75 | 107 |
76 // current unlimited plan shared by multiple tests | 108 // current unlimited plan shared by multiple tests |
77 DataPlan *current_unlimited_plan_; | 109 DataPlan *current_unlimited_plan_; |
78 | 110 |
79 // current available metered plan shared by multiple tests | 111 // current available metered plan shared by multiple tests |
80 DataPlan *current_available_metered_plan_; | 112 DataPlan *current_available_metered_plan_; |
| 113 |
| 114 // three metered plans shared by multiple tests |
| 115 DataPlan *plan_one_; |
| 116 DataPlan *plan_two_; |
| 117 DataPlan *plan_three_; |
| 118 |
| 119 // mocks |
| 120 ServiceMock service_mock_; |
| 121 ServiceManagerMock service_manager_mock_; |
| 122 DeviceMock device_mock_; |
81 }; | 123 }; |
82 | 124 |
83 typedef DataPlanTest DataPlanDeathTest; | 125 typedef DataPlanTest DataPlanDeathTest; |
84 | 126 |
85 const char *DataPlanTest::kMeteredWithUsedBytesJSON = | 127 const char *DataPlanTest::kMeteredWithUsedBytesJSON = |
86 "{\"lastUpdate\" : \"2010-09-20T12:01:00Z\"," | 128 "{\"lastUpdate\" : \"2010-09-20T12:01:00Z\"," |
87 "\"planName\" : \"Super-Awesome Chromium OS Plan\"," | 129 "\"planName\" : \"Super-Awesome Chromium OS Plan\"," |
88 "\"planType\" : \"METERED_PAID\"," | 130 "\"planType\" : \"METERED_PAID\"," |
89 "\"maxBytes\" : 104857600," | 131 "\"maxBytes\" : 104857600," |
90 "\"usedBytes\" : 52428800," | 132 "\"usedBytes\" : 52428800," |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 DataPlan *plan = DataPlan::FromDictionaryValue(dict_value, policy_); | 320 DataPlan *plan = DataPlan::FromDictionaryValue(dict_value, policy_); |
279 // we expect the call to have succeeded and max bytes to be set properly | 321 // we expect the call to have succeeded and max bytes to be set properly |
280 ASSERT_TRUE(plan != NULL); | 322 ASSERT_TRUE(plan != NULL); |
281 EXPECT_EQ(5000000000LL, plan->GetDataBytesMax()); | 323 EXPECT_EQ(5000000000LL, plan->GetDataBytesMax()); |
282 } | 324 } |
283 | 325 |
284 TEST_F(DataPlanTest, TotalBytesAfterCtor) { | 326 TEST_F(DataPlanTest, TotalBytesAfterCtor) { |
285 // this test uses |current_unlimited_plan_| created in fixture SetUp | 327 // this test uses |current_unlimited_plan_| created in fixture SetUp |
286 // we expect plan to be initialized with local bytes == 0 and total bytes == | 328 // we expect plan to be initialized with local bytes == 0 and total bytes == |
287 // |used_bytes| | 329 // |used_bytes| |
288 EXPECT_EQ(5 * 1024 * 1024, current_unlimited_plan_->GetDataBytesUsed()); | 330 EXPECT_EQ(5 * kBytesPerMegabyte, current_unlimited_plan_->GetDataBytesUsed()); |
289 EXPECT_EQ(0, current_unlimited_plan_->GetLocalBytesUsed()); | 331 EXPECT_EQ(0, current_unlimited_plan_->GetLocalBytesUsed()); |
290 EXPECT_EQ(5 * 1024 * 1024, current_unlimited_plan_->GetTotalBytesUsed()); | 332 EXPECT_EQ(5 * kBytesPerMegabyte, |
| 333 current_unlimited_plan_->GetTotalBytesUsed()); |
291 } | 334 } |
292 | 335 |
293 TEST_F(DataPlanTest, TotalBytesAfterSetLocalBytes) { | 336 TEST_F(DataPlanTest, TotalBytesAfterSetLocalBytes) { |
294 // this test uses |current_unlimited_plan_| created in fixture SetUp | 337 // this test uses |current_unlimited_plan_| created in fixture SetUp |
295 Bytes local_bytes = 10 * 1024 * 1024; | 338 Bytes local_bytes = 10 * kBytesPerMegabyte; |
296 current_unlimited_plan_->SetLocalBytesUsed(local_bytes); | 339 current_unlimited_plan_->SetLocalBytesUsed(local_bytes); |
297 // we expect that, after we set local bytes, total bytes == data bytes + | 340 // we expect that, after we set local bytes, total bytes == data bytes + |
298 // local bytes | 341 // local bytes |
299 EXPECT_EQ(5 * 1024 * 1024, current_unlimited_plan_->GetDataBytesUsed()); | 342 EXPECT_EQ(5 * kBytesPerMegabyte, current_unlimited_plan_->GetDataBytesUsed()); |
300 EXPECT_EQ(local_bytes, current_unlimited_plan_->GetLocalBytesUsed()); | 343 EXPECT_EQ(local_bytes, current_unlimited_plan_->GetLocalBytesUsed()); |
301 EXPECT_EQ(15 * 1024 * 1024, current_unlimited_plan_->GetTotalBytesUsed()); | 344 EXPECT_EQ(15 * kBytesPerMegabyte, |
| 345 current_unlimited_plan_->GetTotalBytesUsed()); |
302 } | 346 } |
303 | 347 |
304 TEST_F(DataPlanTest, TotalBytesAfterOverflow) { | 348 TEST_F(DataPlanTest, TotalBytesAfterOverflow) { |
305 // this test uses |current_unlimited_plan_| created in fixture SetUp | 349 // this test uses |current_unlimited_plan_| created in fixture SetUp |
306 Bytes local_bytes = kint64max; | 350 Bytes local_bytes = kint64max; |
307 current_unlimited_plan_->SetLocalBytesUsed(local_bytes); | 351 current_unlimited_plan_->SetLocalBytesUsed(local_bytes); |
308 // we expect that, after we set local bytes to a value that will cause the | 352 // we expect that, after we set local bytes to a value that will cause the |
309 // total bytes computation to overflow, the overflow will be detected and | 353 // total bytes computation to overflow, the overflow will be detected and |
310 // total bytes will be set to kint64max. | 354 // total bytes will be set to kint64max. |
311 EXPECT_EQ(5 * 1024 * 1024, current_unlimited_plan_->GetDataBytesUsed()); | 355 EXPECT_EQ(5 * kBytesPerMegabyte, current_unlimited_plan_->GetDataBytesUsed()); |
312 EXPECT_EQ(local_bytes, current_unlimited_plan_->GetLocalBytesUsed()); | 356 EXPECT_EQ(local_bytes, current_unlimited_plan_->GetLocalBytesUsed()); |
313 EXPECT_EQ(kint64max, current_unlimited_plan_->GetTotalBytesUsed()); | 357 EXPECT_EQ(kint64max, current_unlimited_plan_->GetTotalBytesUsed()); |
314 } | 358 } |
315 | 359 |
316 TEST_F(DataPlanTest, IsActiveCurrentPlan) { | 360 TEST_F(DataPlanTest, IsActiveCurrentPlan) { |
317 std::string name = "Current Plan"; | 361 std::string name = "Current Plan"; |
318 DataPlan::Type type = DataPlan::kTypeMeteredFree; | 362 DataPlan::Type type = DataPlan::kTypeMeteredFree; |
319 base::TimeDelta twelve_hours = base::TimeDelta::FromHours(12); | 363 base::TimeDelta twelve_hours = base::TimeDelta::FromHours(12); |
320 base::Time now = base::Time::Now(); | 364 base::Time now = base::Time::Now(); |
321 base::Time start_time = now - twelve_hours; | 365 base::Time start_time = now - twelve_hours; |
322 base::Time end_time = now + twelve_hours; | 366 base::Time end_time = now + twelve_hours; |
323 Bytes max_bytes = 100 * 1024 * 1024; | 367 Bytes max_bytes = 100 * kBytesPerMegabyte; |
324 Bytes used_bytes = 5 * 1024 * 1024; | 368 Bytes used_bytes = 5 * kBytesPerMegabyte; |
325 DataPlan *plan = new(std::nothrow) DataPlan(name, type, now, start_time, | 369 DataPlan *plan = new(std::nothrow) DataPlan(name, type, now, start_time, |
326 end_time, max_bytes, used_bytes); | 370 end_time, max_bytes, used_bytes); |
327 ASSERT_TRUE(plan != NULL); | 371 ASSERT_TRUE(plan != NULL); |
328 // we expect that a current plan will be considered active | 372 // we expect that a current plan will be considered active |
329 EXPECT_TRUE(plan->IsActive()); | 373 EXPECT_TRUE(plan->IsActive()); |
330 delete plan; | 374 delete plan; |
331 } | 375 } |
332 | 376 |
333 TEST_F(DataPlanTest, IsActiveFuturePlan) { | 377 TEST_F(DataPlanTest, IsActiveFuturePlan) { |
334 std::string name = "Future Plan"; | 378 std::string name = "Future Plan"; |
335 DataPlan::Type type = DataPlan::kTypeMeteredFree; | 379 DataPlan::Type type = DataPlan::kTypeMeteredFree; |
336 base::TimeDelta twelve_hours = base::TimeDelta::FromHours(12); | 380 base::TimeDelta twelve_hours = base::TimeDelta::FromHours(12); |
337 base::Time now = base::Time::Now(); | 381 base::Time now = base::Time::Now(); |
338 base::Time start_time = now + twelve_hours; | 382 base::Time start_time = now + twelve_hours; |
339 base::Time end_time = now + twelve_hours + twelve_hours; | 383 base::Time end_time = now + twelve_hours + twelve_hours; |
340 Bytes max_bytes = 100 * 1024 * 1024; | 384 Bytes max_bytes = 100 * kBytesPerMegabyte; |
341 Bytes used_bytes = 5 * 1024 * 1024; | 385 Bytes used_bytes = 5 * kBytesPerMegabyte; |
342 DataPlan *plan = new(std::nothrow) DataPlan(name, type, now, start_time, | 386 DataPlan *plan = new(std::nothrow) DataPlan(name, type, now, start_time, |
343 end_time, max_bytes, used_bytes); | 387 end_time, max_bytes, used_bytes); |
344 ASSERT_TRUE(plan != NULL); | 388 ASSERT_TRUE(plan != NULL); |
345 // we expect that a future plan will not be considered active | 389 // we expect that a future plan will not be considered active |
346 EXPECT_FALSE(plan->IsActive()); | 390 EXPECT_FALSE(plan->IsActive()); |
347 delete plan; | 391 delete plan; |
348 } | 392 } |
349 | 393 |
350 TEST_F(DataPlanTest, IsActiveExpiredPlan) { | 394 TEST_F(DataPlanTest, IsActiveExpiredPlan) { |
351 std::string name = "Expired Plan"; | 395 std::string name = "Expired Plan"; |
352 DataPlan::Type type = DataPlan::kTypeMeteredFree; | 396 DataPlan::Type type = DataPlan::kTypeMeteredFree; |
353 base::TimeDelta twelve_hours = base::TimeDelta::FromHours(12); | 397 base::TimeDelta twelve_hours = base::TimeDelta::FromHours(12); |
354 base::Time now = base::Time::Now(); | 398 base::Time now = base::Time::Now(); |
355 base::Time start_time = now - twelve_hours - twelve_hours; | 399 base::Time start_time = now - twelve_hours - twelve_hours; |
356 base::Time end_time = now - twelve_hours; | 400 base::Time end_time = now - twelve_hours; |
357 Bytes max_bytes = 100 * 1024 * 1024; | 401 Bytes max_bytes = 100 * kBytesPerMegabyte; |
358 Bytes used_bytes = 5 * 1024 * 1024; | 402 Bytes used_bytes = 5 * kBytesPerMegabyte; |
359 DataPlan *plan = new(std::nothrow) DataPlan(name, type, now, start_time, | 403 DataPlan *plan = new(std::nothrow) DataPlan(name, type, now, start_time, |
360 end_time, max_bytes, used_bytes); | 404 end_time, max_bytes, used_bytes); |
361 ASSERT_TRUE(plan != NULL); | 405 ASSERT_TRUE(plan != NULL); |
362 // we expect that an expired plan will not be considered active | 406 // we expect that an expired plan will not be considered active |
363 EXPECT_FALSE(plan->IsActive()); | 407 EXPECT_FALSE(plan->IsActive()); |
364 delete plan; | 408 delete plan; |
365 } | 409 } |
366 | 410 |
367 TEST_F(DataPlanTest, IsActiveJustStartedPlan) { | 411 TEST_F(DataPlanTest, IsActiveJustStartedPlan) { |
368 std::string name = "Just Started Plan"; | 412 std::string name = "Just Started Plan"; |
369 DataPlan::Type type = DataPlan::kTypeMeteredFree; | 413 DataPlan::Type type = DataPlan::kTypeMeteredFree; |
370 base::TimeDelta twelve_hours = base::TimeDelta::FromHours(12); | 414 base::TimeDelta twelve_hours = base::TimeDelta::FromHours(12); |
371 base::Time now = base::Time::Now(); | 415 base::Time now = base::Time::Now(); |
372 base::Time start_time = now; | 416 base::Time start_time = now; |
373 base::Time end_time = now + twelve_hours; | 417 base::Time end_time = now + twelve_hours; |
374 Bytes max_bytes = 100 * 1024 * 1024; | 418 Bytes max_bytes = 100 * kBytesPerMegabyte; |
375 Bytes used_bytes = 5 * 1024 * 1024; | 419 Bytes used_bytes = 5 * kBytesPerMegabyte; |
376 DataPlan *plan = new(std::nothrow) DataPlan(name, type, now, start_time, | 420 DataPlan *plan = new(std::nothrow) DataPlan(name, type, now, start_time, |
377 end_time, max_bytes, used_bytes); | 421 end_time, max_bytes, used_bytes); |
378 ASSERT_TRUE(plan != NULL); | 422 ASSERT_TRUE(plan != NULL); |
379 // we expect that a plan with start time == now will be considered active | 423 // we expect that a plan with start time == now will be considered active |
380 EXPECT_TRUE(plan->IsActive()); | 424 EXPECT_TRUE(plan->IsActive()); |
381 delete plan; | 425 delete plan; |
382 } | 426 } |
383 | 427 |
384 TEST_F(DataPlanTest, IsActiveJustExpiredPlan) { | 428 TEST_F(DataPlanTest, IsActiveJustExpiredPlan) { |
385 std::string name = "Just Expired Plan"; | 429 std::string name = "Just Expired Plan"; |
386 DataPlan::Type type = DataPlan::kTypeMeteredFree; | 430 DataPlan::Type type = DataPlan::kTypeMeteredFree; |
387 base::TimeDelta twelve_hours = base::TimeDelta::FromHours(12); | 431 base::TimeDelta twelve_hours = base::TimeDelta::FromHours(12); |
388 base::Time now = base::Time::Now(); | 432 base::Time now = base::Time::Now(); |
389 base::Time start_time = now - twelve_hours; | 433 base::Time start_time = now - twelve_hours; |
390 base::Time end_time = now; | 434 base::Time end_time = now; |
391 Bytes max_bytes = 100 * 1024 * 1024; | 435 Bytes max_bytes = 100 * kBytesPerMegabyte; |
392 Bytes used_bytes = 5 * 1024 * 1024; | 436 Bytes used_bytes = 5 * kBytesPerMegabyte; |
393 DataPlan *plan = new(std::nothrow) DataPlan(name, type, now, start_time, | 437 DataPlan *plan = new(std::nothrow) DataPlan(name, type, now, start_time, |
394 end_time, max_bytes, used_bytes); | 438 end_time, max_bytes, used_bytes); |
395 ASSERT_TRUE(plan != NULL); | 439 ASSERT_TRUE(plan != NULL); |
396 // we expect that a plan with end time == now will not be considered active | 440 // we expect that a plan with end time == now will not be considered active |
397 EXPECT_FALSE(plan->IsActive()); | 441 EXPECT_FALSE(plan->IsActive()); |
398 delete plan; | 442 delete plan; |
399 } | 443 } |
400 | 444 |
401 TEST_F(DataPlanTest, IsActiveAvailableMeteredPlan) { | 445 TEST_F(DataPlanTest, IsActiveAvailableMeteredPlan) { |
402 // this test uses |current_available_metered_plan_| created in fixture SetUp | 446 // this test uses |current_available_metered_plan_| created in fixture SetUp |
403 // we expect that a current metered plan that is not yet consumed will be | 447 // we expect that a current metered plan that is not yet consumed will be |
404 // considered active | 448 // considered active |
405 EXPECT_TRUE(current_available_metered_plan_->IsActive()); | 449 EXPECT_TRUE(current_available_metered_plan_->IsActive()); |
406 } | 450 } |
407 | 451 |
408 TEST_F(DataPlanTest, IsActiveConsumedMeteredPlan) { | 452 TEST_F(DataPlanTest, IsActiveConsumedMeteredPlan) { |
409 std::string name = "Consumed Metered Plan"; | 453 std::string name = "Consumed Metered Plan"; |
410 DataPlan::Type type = DataPlan::kTypeMeteredFree; | 454 DataPlan::Type type = DataPlan::kTypeMeteredFree; |
411 base::TimeDelta twelve_hours = base::TimeDelta::FromHours(12); | 455 base::TimeDelta twelve_hours = base::TimeDelta::FromHours(12); |
412 base::Time now = base::Time::Now(); | 456 base::Time now = base::Time::Now(); |
413 base::Time start_time = now - twelve_hours; | 457 base::Time start_time = now - twelve_hours; |
414 base::Time end_time = now + twelve_hours; | 458 base::Time end_time = now + twelve_hours; |
415 Bytes max_bytes = 100 * 1024 * 1024; | 459 Bytes max_bytes = 100 * kBytesPerMegabyte; |
416 Bytes used_bytes = 100 * 1024 * 1024; | 460 Bytes used_bytes = 100 * kBytesPerMegabyte; |
417 DataPlan *plan = new(std::nothrow) DataPlan(name, type, now, start_time, | 461 DataPlan *plan = new(std::nothrow) DataPlan(name, type, now, start_time, |
418 end_time, max_bytes, used_bytes); | 462 end_time, max_bytes, used_bytes); |
419 ASSERT_TRUE(plan != NULL); | 463 ASSERT_TRUE(plan != NULL); |
420 // we expect that a current metered plan that is consumed will not be | 464 // we expect that a current metered plan that is consumed will not be |
421 // considered active | 465 // considered active |
422 EXPECT_FALSE(plan->IsActive()); | 466 EXPECT_FALSE(plan->IsActive()); |
423 delete plan; | 467 delete plan; |
424 } | 468 } |
425 | 469 |
426 TEST_F(DataPlanTest, IsActiveConsumedLocalMeteredPlan) { | 470 TEST_F(DataPlanTest, IsActiveConsumedLocalMeteredPlan) { |
427 // this test uses |current_available_metered_plan_| created in fixture SetUp | 471 // this test uses |current_available_metered_plan_| created in fixture SetUp |
428 current_available_metered_plan_->SetLocalBytesUsed(95 * 1024 * 1024); | 472 current_available_metered_plan_->SetLocalBytesUsed(95 * kBytesPerMegabyte); |
429 // we expect that a current metered plan that has used bytes < max bytes but | 473 // we expect that a current metered plan that has used bytes < max bytes but |
430 // is consumed by virtue of local bytes + used bytes being >= max bytes will | 474 // is consumed by virtue of local bytes + used bytes being >= max bytes will |
431 // not be considered active | 475 // not be considered active |
432 EXPECT_FALSE(current_available_metered_plan_->IsActive()); | 476 EXPECT_FALSE(current_available_metered_plan_->IsActive()); |
433 } | 477 } |
434 | 478 |
435 TEST_F(DataPlanTest, IsActiveUnlimitedPlan) { | 479 TEST_F(DataPlanTest, IsActiveUnlimitedPlan) { |
436 // this test uses |current_unlimited_plan_| created in fixture SetUp | 480 // this test uses |current_unlimited_plan_| created in fixture SetUp |
437 // we expect that a current unlimited plan will be considered active, even if | 481 // we expect that a current unlimited plan will be considered active, even if |
438 // its total bytes is greater than its (meaningless) max bytes | 482 // its total bytes is greater than its (meaningless) max bytes |
439 EXPECT_TRUE(current_unlimited_plan_->IsActive()); | 483 EXPECT_TRUE(current_unlimited_plan_->IsActive()); |
440 } | 484 } |
441 | 485 |
| 486 // tests for local byte counter maintenance across plan transitions |
| 487 |
| 488 // empty list, we should stop the counter |
| 489 TEST_F(DataPlanTest, NoActivePlans) { |
| 490 // create empty list |
| 491 DataPlanList data_plans; |
| 492 ASSERT_TRUE(data_plans.empty()); |
| 493 |
| 494 // set up mock expectations and method return values |
| 495 { |
| 496 testing::InSequence expect_calls_in_order; |
| 497 EXPECT_CALL(device_mock_, ByteCounterRunning()) |
| 498 .WillRepeatedly(testing::Return(true)); |
| 499 EXPECT_CALL(device_mock_, StopByteCounter()).Times(1); |
| 500 } |
| 501 |
| 502 // simulate a byte counter update |
| 503 uint64 rx_bytes = 25 * kBytesPerMegabyte; |
| 504 uint64 tx_bytes = 25 * kBytesPerMegabyte; |
| 505 bool result = DataPlan::OnByteCounterUpdate(&data_plans, &service_mock_, |
| 506 &service_manager_mock_, |
| 507 &device_mock_, rx_bytes, |
| 508 tx_bytes); |
| 509 |
| 510 // check if test passed |
| 511 // failure will most likely manifest as violated mock expectation |
| 512 EXPECT_FALSE(result); |
| 513 } |
| 514 |
| 515 // single plan, usage doesn't consume |
| 516 TEST_F(DataPlanTest, OnePlanNotConsumed) { |
| 517 DataPlanList data_plans; |
| 518 data_plans.push_back(plan_one_); |
| 519 |
| 520 // set up mock expectations and method return values |
| 521 EXPECT_CALL(device_mock_, ByteCounterRunning()) |
| 522 .WillRepeatedly(testing::Return(true)); |
| 523 |
| 524 // simulate a byte counter update |
| 525 uint64 rx_bytes = 25 * kBytesPerMegabyte; |
| 526 uint64 tx_bytes = 25 * kBytesPerMegabyte; |
| 527 bool result = DataPlan::OnByteCounterUpdate(&data_plans, &service_mock_, |
| 528 &service_manager_mock_, |
| 529 &device_mock_, rx_bytes, |
| 530 tx_bytes); |
| 531 |
| 532 // check if test passed |
| 533 EXPECT_TRUE(result); |
| 534 EXPECT_EQ(plan_one_->GetDataBytesMax(), 100 * kBytesPerMegabyte); |
| 535 EXPECT_EQ(plan_one_->GetDataBytesUsed(), 0); |
| 536 EXPECT_EQ(plan_one_->GetLocalBytesUsed(), 50 * kBytesPerMegabyte); |
| 537 EXPECT_EQ(plan_one_->GetTotalBytesUsed(), 50 * kBytesPerMegabyte); |
| 538 EXPECT_TRUE(plan_one_->IsActive()); |
| 539 } |
| 540 |
| 541 // single plan, usage exactly consumes |
| 542 TEST_F(DataPlanTest, OnePlanConsumed) { |
| 543 DataPlanList data_plans; |
| 544 data_plans.push_back(plan_one_); |
| 545 |
| 546 // set up mock expectations and method return values |
| 547 { |
| 548 testing::InSequence expect_calls_in_order; |
| 549 EXPECT_CALL(device_mock_, ByteCounterRunning()) |
| 550 .WillRepeatedly(testing::Return(true)); |
| 551 EXPECT_CALL(service_manager_mock_, |
| 552 OnDataPlanInactive(testing::Ref(service_mock_), |
| 553 testing::Ref(*plan_one_))).Times(1); |
| 554 EXPECT_CALL(device_mock_, ResetByteCounter(0, 0)).Times(1); |
| 555 EXPECT_CALL(device_mock_, StopByteCounter()).Times(1); |
| 556 } |
| 557 |
| 558 // simulate a byte counter update |
| 559 uint64 rx_bytes = 50 * kBytesPerMegabyte; |
| 560 uint64 tx_bytes = 50 * kBytesPerMegabyte; |
| 561 bool result = DataPlan::OnByteCounterUpdate(&data_plans, &service_mock_, |
| 562 &service_manager_mock_, |
| 563 &device_mock_, rx_bytes, |
| 564 tx_bytes); |
| 565 |
| 566 // check if test passed |
| 567 EXPECT_TRUE(result); |
| 568 EXPECT_EQ(plan_one_->GetDataBytesMax(), 100 * kBytesPerMegabyte); |
| 569 EXPECT_EQ(plan_one_->GetDataBytesUsed(), 0); |
| 570 EXPECT_EQ(plan_one_->GetLocalBytesUsed(), 100 * kBytesPerMegabyte); |
| 571 EXPECT_EQ(plan_one_->GetTotalBytesUsed(), 100 * kBytesPerMegabyte); |
| 572 EXPECT_FALSE(plan_one_->IsActive()); |
| 573 } |
| 574 |
| 575 // single plan, usage consumes and leaves overage but no active plan |
| 576 TEST_F(DataPlanTest, OnePlanConsumedWithOverage) { |
| 577 DataPlanList data_plans; |
| 578 data_plans.push_back(plan_one_); |
| 579 |
| 580 // set up mock expectations and method return values |
| 581 { |
| 582 testing::InSequence expect_calls_in_order; |
| 583 EXPECT_CALL(device_mock_, ByteCounterRunning()) |
| 584 .WillRepeatedly(testing::Return(true)); |
| 585 EXPECT_CALL(service_manager_mock_, |
| 586 OnDataPlanInactive(testing::Ref(service_mock_), |
| 587 testing::Ref(*plan_one_))).Times(1); |
| 588 EXPECT_CALL(device_mock_, ResetByteCounter(10 * kBytesPerMegabyte, |
| 589 0)).Times(1); |
| 590 EXPECT_CALL(device_mock_, StopByteCounter()).Times(1); |
| 591 } |
| 592 |
| 593 // simulate a byte counter update |
| 594 uint64 rx_bytes = 55 * kBytesPerMegabyte; |
| 595 uint64 tx_bytes = 55 * kBytesPerMegabyte; |
| 596 bool result = DataPlan::OnByteCounterUpdate(&data_plans, &service_mock_, |
| 597 &service_manager_mock_, |
| 598 &device_mock_, rx_bytes, |
| 599 tx_bytes); |
| 600 |
| 601 // check if test passed |
| 602 EXPECT_TRUE(result); |
| 603 EXPECT_EQ(plan_one_->GetDataBytesMax(), 100 * kBytesPerMegabyte); |
| 604 EXPECT_EQ(plan_one_->GetDataBytesUsed(), 0); |
| 605 EXPECT_EQ(plan_one_->GetLocalBytesUsed(), 100 * kBytesPerMegabyte); |
| 606 EXPECT_EQ(plan_one_->GetTotalBytesUsed(), 100 * kBytesPerMegabyte); |
| 607 EXPECT_FALSE(plan_one_->IsActive()); |
| 608 } |
| 609 |
| 610 // two plans, first is inactive because quota consumed and second is active |
| 611 // usage is applied to but does not consume second plan |
| 612 TEST_F(DataPlanTest, TwoPlansFirstInactiveConsumed) { |
| 613 // create consumed plan and put it in list |
| 614 std::string name = "Consumed Plan"; |
| 615 DataPlan::Type type = DataPlan::kTypeMeteredFree; |
| 616 base::TimeDelta twelve_hours = base::TimeDelta::FromHours(12); |
| 617 base::Time now = base::Time::Now(); |
| 618 base::Time start_time = now - twelve_hours; |
| 619 base::Time end_time = now + twelve_hours; |
| 620 Bytes max_bytes = 100 * kBytesPerMegabyte; |
| 621 Bytes used_bytes = 100 * kBytesPerMegabyte; |
| 622 DataPlan *consumed_plan = new(std::nothrow) DataPlan(name, type, now, |
| 623 start_time, end_time, |
| 624 max_bytes, used_bytes); |
| 625 ASSERT_TRUE(consumed_plan != NULL); |
| 626 DataPlanList data_plans; |
| 627 data_plans.push_back(consumed_plan); |
| 628 |
| 629 // use active plan from test fixture |
| 630 data_plans.push_back(plan_two_); |
| 631 |
| 632 // set up mock expectations and method return values |
| 633 EXPECT_CALL(device_mock_, ByteCounterRunning()) |
| 634 .WillRepeatedly(testing::Return(true)); |
| 635 |
| 636 // simulate a byte counter update |
| 637 uint64 rx_bytes = 25 * kBytesPerMegabyte; |
| 638 uint64 tx_bytes = 25 * kBytesPerMegabyte; |
| 639 bool result = DataPlan::OnByteCounterUpdate(&data_plans, &service_mock_, |
| 640 &service_manager_mock_, |
| 641 &device_mock_, rx_bytes, |
| 642 tx_bytes); |
| 643 |
| 644 // check if test passed |
| 645 EXPECT_TRUE(result); |
| 646 EXPECT_EQ(consumed_plan->GetDataBytesMax(), 100 * kBytesPerMegabyte); |
| 647 EXPECT_EQ(consumed_plan->GetDataBytesUsed(), 100 * kBytesPerMegabyte); |
| 648 EXPECT_EQ(consumed_plan->GetLocalBytesUsed(), 0); |
| 649 EXPECT_EQ(consumed_plan->GetTotalBytesUsed(), 100 * kBytesPerMegabyte); |
| 650 EXPECT_FALSE(consumed_plan->IsActive()); |
| 651 EXPECT_EQ(plan_two_->GetDataBytesMax(), 100 * kBytesPerMegabyte); |
| 652 EXPECT_EQ(plan_two_->GetDataBytesUsed(), 0); |
| 653 EXPECT_EQ(plan_two_->GetLocalBytesUsed(), 50 * kBytesPerMegabyte); |
| 654 EXPECT_EQ(plan_two_->GetTotalBytesUsed(), 50 * kBytesPerMegabyte); |
| 655 EXPECT_TRUE(plan_two_->IsActive()); |
| 656 |
| 657 // clean up |
| 658 delete consumed_plan; |
| 659 } |
| 660 |
| 661 // two plans, first is inactive because it has expired and second is active |
| 662 // usage is applied to but does not consume second plan |
| 663 TEST_F(DataPlanTest, TwoPlansFirstInactiveExpired) { |
| 664 // create expired plan and put it in list |
| 665 std::string name = "Expired Plan"; |
| 666 DataPlan::Type type = DataPlan::kTypeMeteredFree; |
| 667 base::TimeDelta twelve_hours = base::TimeDelta::FromHours(12); |
| 668 base::Time now = base::Time::Now(); |
| 669 base::Time start_time = now - 2 * twelve_hours; |
| 670 base::Time end_time = now - twelve_hours; |
| 671 Bytes max_bytes = 100 * kBytesPerMegabyte; |
| 672 Bytes used_bytes = 0; |
| 673 DataPlan *expired_plan = new(std::nothrow) DataPlan(name, type, now, |
| 674 start_time, end_time, |
| 675 max_bytes, used_bytes); |
| 676 ASSERT_TRUE(expired_plan != NULL); |
| 677 DataPlanList data_plans; |
| 678 data_plans.push_back(expired_plan); |
| 679 |
| 680 // use active plan from test fixture |
| 681 data_plans.push_back(plan_two_); |
| 682 |
| 683 // set up mock expectations and method return values |
| 684 EXPECT_CALL(device_mock_, ByteCounterRunning()) |
| 685 .WillRepeatedly(testing::Return(true)); |
| 686 |
| 687 // simulate a byte counter update |
| 688 uint64 rx_bytes = 25 * kBytesPerMegabyte; |
| 689 uint64 tx_bytes = 25 * kBytesPerMegabyte; |
| 690 bool result = DataPlan::OnByteCounterUpdate(&data_plans, &service_mock_, |
| 691 &service_manager_mock_, |
| 692 &device_mock_, rx_bytes, |
| 693 tx_bytes); |
| 694 |
| 695 // check if test passed |
| 696 EXPECT_TRUE(result); |
| 697 EXPECT_EQ(expired_plan->GetDataBytesMax(), 100 * kBytesPerMegabyte); |
| 698 EXPECT_EQ(expired_plan->GetDataBytesUsed(), 0); |
| 699 EXPECT_EQ(expired_plan->GetLocalBytesUsed(), 0); |
| 700 EXPECT_EQ(expired_plan->GetTotalBytesUsed(), 0); |
| 701 EXPECT_FALSE(expired_plan->IsActive()); |
| 702 EXPECT_EQ(plan_two_->GetDataBytesMax(), 100 * kBytesPerMegabyte); |
| 703 EXPECT_EQ(plan_two_->GetDataBytesUsed(), 0); |
| 704 EXPECT_EQ(plan_two_->GetLocalBytesUsed(), 50 * kBytesPerMegabyte); |
| 705 EXPECT_EQ(plan_two_->GetTotalBytesUsed(), 50 * kBytesPerMegabyte); |
| 706 EXPECT_TRUE(plan_two_->IsActive()); |
| 707 |
| 708 // clean up |
| 709 delete expired_plan; |
| 710 } |
| 711 |
| 712 // two plans, first is unlimited and should absorb all usage |
| 713 // second plan should remain untouched |
| 714 TEST_F(DataPlanTest, TwoPlansFirstUnlimited) { |
| 715 // use plans from test fixture |
| 716 DataPlanList data_plans; |
| 717 data_plans.push_back(current_unlimited_plan_); |
| 718 data_plans.push_back(plan_two_); |
| 719 |
| 720 // set up mock expectations and method return values |
| 721 EXPECT_CALL(device_mock_, ByteCounterRunning()) |
| 722 .WillRepeatedly(testing::Return(true)); |
| 723 |
| 724 // simulate a byte counter update |
| 725 uint64 rx_bytes = 100 * kBytesPerMegabyte; |
| 726 uint64 tx_bytes = 100 * kBytesPerMegabyte; |
| 727 bool result = DataPlan::OnByteCounterUpdate(&data_plans, &service_mock_, |
| 728 &service_manager_mock_, |
| 729 &device_mock_, rx_bytes, |
| 730 tx_bytes); |
| 731 |
| 732 // check if test passed |
| 733 EXPECT_TRUE(result); |
| 734 EXPECT_EQ(current_unlimited_plan_->GetDataBytesMax(), 0); |
| 735 EXPECT_EQ(current_unlimited_plan_->GetDataBytesUsed(), 5 * kBytesPerMegabyte); |
| 736 EXPECT_EQ(current_unlimited_plan_->GetLocalBytesUsed(), |
| 737 200 * kBytesPerMegabyte); |
| 738 EXPECT_EQ(current_unlimited_plan_->GetTotalBytesUsed(), |
| 739 205 * kBytesPerMegabyte); |
| 740 EXPECT_TRUE(current_unlimited_plan_->IsActive()); |
| 741 EXPECT_EQ(plan_two_->GetDataBytesMax(), 100 * kBytesPerMegabyte); |
| 742 EXPECT_EQ(plan_two_->GetDataBytesUsed(), 0); |
| 743 EXPECT_EQ(plan_two_->GetLocalBytesUsed(), 0); |
| 744 EXPECT_EQ(plan_two_->GetTotalBytesUsed(), 0); |
| 745 EXPECT_TRUE(plan_two_->IsActive()); |
| 746 } |
| 747 |
| 748 // two plans, the first is metered and the second is unlimited |
| 749 // usage consumes the first plan, and the overage is absorbed by the second |
| 750 TEST_F(DataPlanTest, TwoPlansSecondUnlimited) { |
| 751 // use plans from test fixture |
| 752 DataPlanList data_plans; |
| 753 data_plans.push_back(plan_one_); |
| 754 data_plans.push_back(current_unlimited_plan_); |
| 755 |
| 756 // set up mock expectations and method return values |
| 757 { |
| 758 testing::InSequence expect_calls_in_order; |
| 759 EXPECT_CALL(device_mock_, ByteCounterRunning()) |
| 760 .WillRepeatedly(testing::Return(true)); |
| 761 EXPECT_CALL(service_manager_mock_, |
| 762 OnDataPlanInactive(testing::Ref(service_mock_), |
| 763 testing::Ref(*plan_one_))).Times(1); |
| 764 EXPECT_CALL(device_mock_, ResetByteCounter(50 * kBytesPerMegabyte, |
| 765 0)).Times(1); |
| 766 } |
| 767 |
| 768 // simulate a byte counter update |
| 769 uint64 rx_bytes = 75 * kBytesPerMegabyte; |
| 770 uint64 tx_bytes = 75 * kBytesPerMegabyte; |
| 771 bool result = DataPlan::OnByteCounterUpdate(&data_plans, &service_mock_, |
| 772 &service_manager_mock_, |
| 773 &device_mock_, rx_bytes, |
| 774 tx_bytes); |
| 775 |
| 776 // check if test passed |
| 777 EXPECT_TRUE(result); |
| 778 EXPECT_EQ(plan_one_->GetDataBytesMax(), 100 * kBytesPerMegabyte); |
| 779 EXPECT_EQ(plan_one_->GetDataBytesUsed(), 0); |
| 780 EXPECT_EQ(plan_one_->GetLocalBytesUsed(), 100 * kBytesPerMegabyte); |
| 781 EXPECT_EQ(plan_one_->GetTotalBytesUsed(), 100 * kBytesPerMegabyte); |
| 782 EXPECT_FALSE(plan_one_->IsActive()); |
| 783 EXPECT_EQ(current_unlimited_plan_->GetDataBytesMax(), 0); |
| 784 EXPECT_EQ(current_unlimited_plan_->GetDataBytesUsed(), 5 * kBytesPerMegabyte); |
| 785 EXPECT_EQ(current_unlimited_plan_->GetLocalBytesUsed(), |
| 786 50 * kBytesPerMegabyte); |
| 787 EXPECT_EQ(current_unlimited_plan_->GetTotalBytesUsed(), |
| 788 55 * kBytesPerMegabyte); |
| 789 EXPECT_TRUE(current_unlimited_plan_->IsActive()); |
| 790 } |
| 791 |
| 792 // two plans, usage doesn't consume first |
| 793 TEST_F(DataPlanTest, TwoPlansFirstNotConsumed) { |
| 794 DataPlanList data_plans; |
| 795 data_plans.push_back(plan_one_); |
| 796 data_plans.push_back(plan_two_); |
| 797 |
| 798 // set up mock expectations and method return values |
| 799 EXPECT_CALL(device_mock_, ByteCounterRunning()) |
| 800 .WillRepeatedly(testing::Return(true)); |
| 801 |
| 802 // simulate a byte counter update |
| 803 uint64 rx_bytes = 25 * kBytesPerMegabyte; |
| 804 uint64 tx_bytes = 25 * kBytesPerMegabyte; |
| 805 bool result = DataPlan::OnByteCounterUpdate(&data_plans, &service_mock_, |
| 806 &service_manager_mock_, |
| 807 &device_mock_, rx_bytes, |
| 808 tx_bytes); |
| 809 |
| 810 // check if test passed |
| 811 EXPECT_TRUE(result); |
| 812 EXPECT_EQ(plan_one_->GetDataBytesMax(), 100 * kBytesPerMegabyte); |
| 813 EXPECT_EQ(plan_one_->GetDataBytesUsed(), 0); |
| 814 EXPECT_EQ(plan_one_->GetLocalBytesUsed(), 50 * kBytesPerMegabyte); |
| 815 EXPECT_EQ(plan_one_->GetTotalBytesUsed(), 50 * kBytesPerMegabyte); |
| 816 EXPECT_TRUE(plan_one_->IsActive()); |
| 817 EXPECT_EQ(plan_two_->GetDataBytesMax(), 100 * kBytesPerMegabyte); |
| 818 EXPECT_EQ(plan_two_->GetDataBytesUsed(), 0); |
| 819 EXPECT_EQ(plan_two_->GetLocalBytesUsed(), 0); |
| 820 EXPECT_EQ(plan_two_->GetTotalBytesUsed(), 0); |
| 821 EXPECT_TRUE(plan_two_->IsActive()); |
| 822 } |
| 823 |
| 824 // two plans, usage consumes first, doesn't consume second |
| 825 TEST_F(DataPlanTest, TwoPlansSecondNotConsumed) { |
| 826 DataPlanList data_plans; |
| 827 data_plans.push_back(plan_one_); |
| 828 data_plans.push_back(plan_two_); |
| 829 |
| 830 // set up mock expectations and method return values |
| 831 { |
| 832 testing::InSequence expect_calls_in_order; |
| 833 EXPECT_CALL(device_mock_, ByteCounterRunning()) |
| 834 .WillRepeatedly(testing::Return(true)); |
| 835 EXPECT_CALL(service_manager_mock_, |
| 836 OnDataPlanInactive(testing::Ref(service_mock_), |
| 837 testing::Ref(*plan_one_))).Times(1); |
| 838 EXPECT_CALL(device_mock_, ResetByteCounter(50 * kBytesPerMegabyte, |
| 839 0)).Times(1); |
| 840 } |
| 841 |
| 842 // simulate a byte counter update |
| 843 uint64 rx_bytes = 75 * kBytesPerMegabyte; |
| 844 uint64 tx_bytes = 75 * kBytesPerMegabyte; |
| 845 bool result = DataPlan::OnByteCounterUpdate(&data_plans, &service_mock_, |
| 846 &service_manager_mock_, |
| 847 &device_mock_, rx_bytes, |
| 848 tx_bytes); |
| 849 |
| 850 // check if test passed |
| 851 EXPECT_TRUE(result); |
| 852 EXPECT_EQ(plan_one_->GetDataBytesMax(), 100 * kBytesPerMegabyte); |
| 853 EXPECT_EQ(plan_one_->GetDataBytesUsed(), 0); |
| 854 EXPECT_EQ(plan_one_->GetLocalBytesUsed(), 100 * kBytesPerMegabyte); |
| 855 EXPECT_EQ(plan_one_->GetTotalBytesUsed(), 100 * kBytesPerMegabyte); |
| 856 EXPECT_FALSE(plan_one_->IsActive()); |
| 857 EXPECT_EQ(plan_two_->GetDataBytesMax(), 100 * kBytesPerMegabyte); |
| 858 EXPECT_EQ(plan_two_->GetDataBytesUsed(), 0); |
| 859 EXPECT_EQ(plan_two_->GetLocalBytesUsed(), 50 * kBytesPerMegabyte); |
| 860 EXPECT_EQ(plan_two_->GetTotalBytesUsed(), 50 * kBytesPerMegabyte); |
| 861 EXPECT_TRUE(plan_two_->IsActive()); |
| 862 } |
| 863 |
| 864 // two plans, usage consumes first, consumes second exactly |
| 865 TEST_F(DataPlanTest, TwoPlansSecondConsumed) { |
| 866 DataPlanList data_plans; |
| 867 data_plans.push_back(plan_one_); |
| 868 data_plans.push_back(plan_two_); |
| 869 |
| 870 // set up mock expectations and method return values |
| 871 { |
| 872 testing::InSequence expect_calls_in_order; |
| 873 EXPECT_CALL(device_mock_, ByteCounterRunning()) |
| 874 .WillRepeatedly(testing::Return(true)); |
| 875 EXPECT_CALL(service_manager_mock_, |
| 876 OnDataPlanInactive(testing::Ref(service_mock_), |
| 877 testing::Ref(*plan_one_))).Times(1); |
| 878 EXPECT_CALL(device_mock_, ResetByteCounter(100 * kBytesPerMegabyte, |
| 879 0)).Times(1); |
| 880 EXPECT_CALL(service_manager_mock_, |
| 881 OnDataPlanInactive(testing::Ref(service_mock_), |
| 882 testing::Ref(*plan_two_))).Times(1); |
| 883 EXPECT_CALL(device_mock_, ResetByteCounter(0, 0)).Times(1); |
| 884 EXPECT_CALL(device_mock_, StopByteCounter()).Times(1); |
| 885 } |
| 886 |
| 887 // simulate a byte counter update |
| 888 uint64 rx_bytes = 100 * kBytesPerMegabyte; |
| 889 uint64 tx_bytes = 100 * kBytesPerMegabyte; |
| 890 bool result = DataPlan::OnByteCounterUpdate(&data_plans, &service_mock_, |
| 891 &service_manager_mock_, |
| 892 &device_mock_, rx_bytes, |
| 893 tx_bytes); |
| 894 |
| 895 // check if test passed |
| 896 EXPECT_TRUE(result); |
| 897 EXPECT_EQ(plan_one_->GetDataBytesMax(), 100 * kBytesPerMegabyte); |
| 898 EXPECT_EQ(plan_one_->GetDataBytesUsed(), 0); |
| 899 EXPECT_EQ(plan_one_->GetLocalBytesUsed(), 100 * kBytesPerMegabyte); |
| 900 EXPECT_EQ(plan_one_->GetTotalBytesUsed(), 100 * kBytesPerMegabyte); |
| 901 EXPECT_FALSE(plan_one_->IsActive()); |
| 902 EXPECT_EQ(plan_two_->GetDataBytesMax(), 100 * kBytesPerMegabyte); |
| 903 EXPECT_EQ(plan_two_->GetDataBytesUsed(), 0); |
| 904 EXPECT_EQ(plan_two_->GetLocalBytesUsed(), 100 * kBytesPerMegabyte); |
| 905 EXPECT_EQ(plan_two_->GetTotalBytesUsed(), 100 * kBytesPerMegabyte); |
| 906 EXPECT_FALSE(plan_two_->IsActive()); |
| 907 } |
| 908 |
| 909 // two plans, usage consumes first, consumes second, with overage |
| 910 TEST_F(DataPlanTest, TwoPlansSecondConsumedWithOverage) { |
| 911 DataPlanList data_plans; |
| 912 data_plans.push_back(plan_one_); |
| 913 data_plans.push_back(plan_two_); |
| 914 |
| 915 // set up mock expectations and method return values |
| 916 { |
| 917 testing::InSequence expect_calls_in_order; |
| 918 EXPECT_CALL(device_mock_, ByteCounterRunning()) |
| 919 .WillRepeatedly(testing::Return(true)); |
| 920 EXPECT_CALL(service_manager_mock_, |
| 921 OnDataPlanInactive(testing::Ref(service_mock_), |
| 922 testing::Ref(*plan_one_))).Times(1); |
| 923 EXPECT_CALL(device_mock_, ResetByteCounter(110 * kBytesPerMegabyte, |
| 924 0)).Times(1); |
| 925 EXPECT_CALL(service_manager_mock_, |
| 926 OnDataPlanInactive(testing::Ref(service_mock_), |
| 927 testing::Ref(*plan_two_))).Times(1); |
| 928 EXPECT_CALL(device_mock_, ResetByteCounter(10 * kBytesPerMegabyte, |
| 929 0)).Times(1); |
| 930 EXPECT_CALL(device_mock_, StopByteCounter()).Times(1); |
| 931 } |
| 932 |
| 933 // simulate a byte counter update |
| 934 uint64 rx_bytes = 105 * kBytesPerMegabyte; |
| 935 uint64 tx_bytes = 105 * kBytesPerMegabyte; |
| 936 bool result = DataPlan::OnByteCounterUpdate(&data_plans, &service_mock_, |
| 937 &service_manager_mock_, |
| 938 &device_mock_, rx_bytes, |
| 939 tx_bytes); |
| 940 |
| 941 // check if test passed |
| 942 EXPECT_TRUE(result); |
| 943 EXPECT_EQ(plan_one_->GetDataBytesMax(), 100 * kBytesPerMegabyte); |
| 944 EXPECT_EQ(plan_one_->GetDataBytesUsed(), 0); |
| 945 EXPECT_EQ(plan_one_->GetLocalBytesUsed(), 100 * kBytesPerMegabyte); |
| 946 EXPECT_EQ(plan_one_->GetTotalBytesUsed(), 100 * kBytesPerMegabyte); |
| 947 EXPECT_FALSE(plan_one_->IsActive()); |
| 948 EXPECT_EQ(plan_two_->GetDataBytesMax(), 100 * kBytesPerMegabyte); |
| 949 EXPECT_EQ(plan_two_->GetDataBytesUsed(), 0); |
| 950 EXPECT_EQ(plan_two_->GetLocalBytesUsed(), 100 * kBytesPerMegabyte); |
| 951 EXPECT_EQ(plan_two_->GetTotalBytesUsed(), 100 * kBytesPerMegabyte); |
| 952 EXPECT_FALSE(plan_two_->IsActive()); |
| 953 } |
| 954 |
| 955 // three plans, usage doesn't consume first |
| 956 TEST_F(DataPlanTest, ThreePlansFirstNotConsumed) { |
| 957 DataPlanList data_plans; |
| 958 data_plans.push_back(plan_one_); |
| 959 data_plans.push_back(plan_two_); |
| 960 data_plans.push_back(plan_three_); |
| 961 |
| 962 // set up mock expectations and method return values |
| 963 EXPECT_CALL(device_mock_, ByteCounterRunning()) |
| 964 .WillRepeatedly(testing::Return(true)); |
| 965 |
| 966 // simulate a byte counter update |
| 967 uint64 rx_bytes = 25 * kBytesPerMegabyte; |
| 968 uint64 tx_bytes = 25 * kBytesPerMegabyte; |
| 969 bool result = DataPlan::OnByteCounterUpdate(&data_plans, &service_mock_, |
| 970 &service_manager_mock_, |
| 971 &device_mock_, rx_bytes, |
| 972 tx_bytes); |
| 973 |
| 974 // check if test passed |
| 975 EXPECT_TRUE(result); |
| 976 EXPECT_EQ(plan_one_->GetDataBytesMax(), 100 * kBytesPerMegabyte); |
| 977 EXPECT_EQ(plan_one_->GetDataBytesUsed(), 0); |
| 978 EXPECT_EQ(plan_one_->GetLocalBytesUsed(), 50 * kBytesPerMegabyte); |
| 979 EXPECT_EQ(plan_one_->GetTotalBytesUsed(), 50 * kBytesPerMegabyte); |
| 980 EXPECT_TRUE(plan_one_->IsActive()); |
| 981 EXPECT_EQ(plan_two_->GetDataBytesMax(), 100 * kBytesPerMegabyte); |
| 982 EXPECT_EQ(plan_two_->GetDataBytesUsed(), 0); |
| 983 EXPECT_EQ(plan_two_->GetLocalBytesUsed(), 0); |
| 984 EXPECT_EQ(plan_two_->GetTotalBytesUsed(), 0); |
| 985 EXPECT_TRUE(plan_two_->IsActive()); |
| 986 EXPECT_EQ(plan_three_->GetDataBytesMax(), 100 * kBytesPerMegabyte); |
| 987 EXPECT_EQ(plan_three_->GetDataBytesUsed(), 0); |
| 988 EXPECT_EQ(plan_three_->GetLocalBytesUsed(), 0); |
| 989 EXPECT_EQ(plan_three_->GetTotalBytesUsed(), 0); |
| 990 EXPECT_TRUE(plan_three_->IsActive()); |
| 991 } |
| 992 |
| 993 // three plans, usage consumes first, doesn't consume second |
| 994 TEST_F(DataPlanTest, ThreePlansSecondNotConsumed) { |
| 995 DataPlanList data_plans; |
| 996 data_plans.push_back(plan_one_); |
| 997 data_plans.push_back(plan_two_); |
| 998 data_plans.push_back(plan_three_); |
| 999 |
| 1000 // set up mock expectations and method return values |
| 1001 { |
| 1002 testing::InSequence expect_calls_in_order; |
| 1003 EXPECT_CALL(device_mock_, ByteCounterRunning()) |
| 1004 .WillRepeatedly(testing::Return(true)); |
| 1005 EXPECT_CALL(service_manager_mock_, |
| 1006 OnDataPlanInactive(testing::Ref(service_mock_), |
| 1007 testing::Ref(*plan_one_))).Times(1); |
| 1008 EXPECT_CALL(device_mock_, ResetByteCounter(50 * kBytesPerMegabyte, |
| 1009 0)).Times(1); |
| 1010 } |
| 1011 |
| 1012 // simulate a byte counter update |
| 1013 uint64 rx_bytes = 75 * kBytesPerMegabyte; |
| 1014 uint64 tx_bytes = 75 * kBytesPerMegabyte; |
| 1015 bool result = DataPlan::OnByteCounterUpdate(&data_plans, &service_mock_, |
| 1016 &service_manager_mock_, |
| 1017 &device_mock_, rx_bytes, |
| 1018 tx_bytes); |
| 1019 |
| 1020 // check if test passed |
| 1021 EXPECT_TRUE(result); |
| 1022 EXPECT_EQ(plan_one_->GetDataBytesMax(), 100 * kBytesPerMegabyte); |
| 1023 EXPECT_EQ(plan_one_->GetDataBytesUsed(), 0); |
| 1024 EXPECT_EQ(plan_one_->GetLocalBytesUsed(), 100 * kBytesPerMegabyte); |
| 1025 EXPECT_EQ(plan_one_->GetTotalBytesUsed(), 100 * kBytesPerMegabyte); |
| 1026 EXPECT_FALSE(plan_one_->IsActive()); |
| 1027 EXPECT_EQ(plan_two_->GetDataBytesMax(), 100 * kBytesPerMegabyte); |
| 1028 EXPECT_EQ(plan_two_->GetDataBytesUsed(), 0); |
| 1029 EXPECT_EQ(plan_two_->GetLocalBytesUsed(), 50 * kBytesPerMegabyte); |
| 1030 EXPECT_EQ(plan_two_->GetTotalBytesUsed(), 50 * kBytesPerMegabyte); |
| 1031 EXPECT_TRUE(plan_two_->IsActive()); |
| 1032 EXPECT_EQ(plan_three_->GetDataBytesMax(), 100 * kBytesPerMegabyte); |
| 1033 EXPECT_EQ(plan_three_->GetDataBytesUsed(), 0); |
| 1034 EXPECT_EQ(plan_three_->GetLocalBytesUsed(), 0); |
| 1035 EXPECT_EQ(plan_three_->GetTotalBytesUsed(), 0); |
| 1036 EXPECT_TRUE(plan_three_->IsActive()); |
| 1037 } |
| 1038 |
| 1039 // three plans, usage consumes first, consumes second, doesn't consume third |
| 1040 TEST_F(DataPlanTest, ThreePlansThirdNotConsumed) { |
| 1041 DataPlanList data_plans; |
| 1042 data_plans.push_back(plan_one_); |
| 1043 data_plans.push_back(plan_two_); |
| 1044 data_plans.push_back(plan_three_); |
| 1045 |
| 1046 // set up mock expectations and method return values |
| 1047 { |
| 1048 testing::InSequence expect_calls_in_order; |
| 1049 EXPECT_CALL(device_mock_, ByteCounterRunning()) |
| 1050 .WillRepeatedly(testing::Return(true)); |
| 1051 EXPECT_CALL(service_manager_mock_, |
| 1052 OnDataPlanInactive(testing::Ref(service_mock_), |
| 1053 testing::Ref(*plan_one_))).Times(1); |
| 1054 EXPECT_CALL(device_mock_, ResetByteCounter(150 * kBytesPerMegabyte, |
| 1055 0)).Times(1); |
| 1056 EXPECT_CALL(service_manager_mock_, |
| 1057 OnDataPlanInactive(testing::Ref(service_mock_), |
| 1058 testing::Ref(*plan_two_))).Times(1); |
| 1059 EXPECT_CALL(device_mock_, ResetByteCounter(50 * kBytesPerMegabyte, |
| 1060 0)).Times(1); |
| 1061 } |
| 1062 |
| 1063 // simulate a byte counter update |
| 1064 uint64 rx_bytes = 125 * kBytesPerMegabyte; |
| 1065 uint64 tx_bytes = 125 * kBytesPerMegabyte; |
| 1066 bool result = DataPlan::OnByteCounterUpdate(&data_plans, &service_mock_, |
| 1067 &service_manager_mock_, |
| 1068 &device_mock_, rx_bytes, |
| 1069 tx_bytes); |
| 1070 |
| 1071 // check if test passed |
| 1072 EXPECT_TRUE(result); |
| 1073 EXPECT_EQ(plan_one_->GetDataBytesMax(), 100 * kBytesPerMegabyte); |
| 1074 EXPECT_EQ(plan_one_->GetDataBytesUsed(), 0); |
| 1075 EXPECT_EQ(plan_one_->GetLocalBytesUsed(), 100 * kBytesPerMegabyte); |
| 1076 EXPECT_EQ(plan_one_->GetTotalBytesUsed(), 100 * kBytesPerMegabyte); |
| 1077 EXPECT_FALSE(plan_one_->IsActive()); |
| 1078 EXPECT_EQ(plan_two_->GetDataBytesMax(), 100 * kBytesPerMegabyte); |
| 1079 EXPECT_EQ(plan_two_->GetDataBytesUsed(), 0); |
| 1080 EXPECT_EQ(plan_two_->GetLocalBytesUsed(), 100 * kBytesPerMegabyte); |
| 1081 EXPECT_EQ(plan_two_->GetTotalBytesUsed(), 100 * kBytesPerMegabyte); |
| 1082 EXPECT_FALSE(plan_two_->IsActive()); |
| 1083 EXPECT_EQ(plan_three_->GetDataBytesMax(), 100 * kBytesPerMegabyte); |
| 1084 EXPECT_EQ(plan_three_->GetDataBytesUsed(), 0); |
| 1085 EXPECT_EQ(plan_three_->GetLocalBytesUsed(), 50 * kBytesPerMegabyte); |
| 1086 EXPECT_EQ(plan_three_->GetTotalBytesUsed(), 50 * kBytesPerMegabyte); |
| 1087 EXPECT_TRUE(plan_three_->IsActive()); |
| 1088 } |
| 1089 |
| 1090 // three plans, usage consumes first, consumes second, exactly consumes third |
| 1091 TEST_F(DataPlanTest, ThreePlansThirdConsumed) { |
| 1092 DataPlanList data_plans; |
| 1093 data_plans.push_back(plan_one_); |
| 1094 data_plans.push_back(plan_two_); |
| 1095 data_plans.push_back(plan_three_); |
| 1096 |
| 1097 // set up mock expectations and method return values |
| 1098 { |
| 1099 testing::InSequence expect_calls_in_order; |
| 1100 EXPECT_CALL(device_mock_, ByteCounterRunning()) |
| 1101 .WillRepeatedly(testing::Return(true)); |
| 1102 EXPECT_CALL(service_manager_mock_, |
| 1103 OnDataPlanInactive(testing::Ref(service_mock_), |
| 1104 testing::Ref(*plan_one_))).Times(1); |
| 1105 EXPECT_CALL(device_mock_, ResetByteCounter(200 * kBytesPerMegabyte, |
| 1106 0)).Times(1); |
| 1107 EXPECT_CALL(service_manager_mock_, |
| 1108 OnDataPlanInactive(testing::Ref(service_mock_), |
| 1109 testing::Ref(*plan_two_))).Times(1); |
| 1110 EXPECT_CALL(device_mock_, ResetByteCounter(100 * kBytesPerMegabyte, |
| 1111 0)).Times(1); |
| 1112 EXPECT_CALL(service_manager_mock_, |
| 1113 OnDataPlanInactive(testing::Ref(service_mock_), |
| 1114 testing::Ref(*plan_three_))).Times(1); |
| 1115 EXPECT_CALL(device_mock_, ResetByteCounter(0, 0)).Times(1); |
| 1116 EXPECT_CALL(device_mock_, StopByteCounter()).Times(1); |
| 1117 } |
| 1118 |
| 1119 // simulate a byte counter update |
| 1120 uint64 rx_bytes = 150 * kBytesPerMegabyte; |
| 1121 uint64 tx_bytes = 150 * kBytesPerMegabyte; |
| 1122 bool result = DataPlan::OnByteCounterUpdate(&data_plans, &service_mock_, |
| 1123 &service_manager_mock_, |
| 1124 &device_mock_, rx_bytes, |
| 1125 tx_bytes); |
| 1126 |
| 1127 // check if test passed |
| 1128 EXPECT_TRUE(result); |
| 1129 EXPECT_EQ(plan_one_->GetDataBytesMax(), 100 * kBytesPerMegabyte); |
| 1130 EXPECT_EQ(plan_one_->GetDataBytesUsed(), 0); |
| 1131 EXPECT_EQ(plan_one_->GetLocalBytesUsed(), 100 * kBytesPerMegabyte); |
| 1132 EXPECT_EQ(plan_one_->GetTotalBytesUsed(), 100 * kBytesPerMegabyte); |
| 1133 EXPECT_FALSE(plan_one_->IsActive()); |
| 1134 EXPECT_EQ(plan_two_->GetDataBytesMax(), 100 * kBytesPerMegabyte); |
| 1135 EXPECT_EQ(plan_two_->GetDataBytesUsed(), 0); |
| 1136 EXPECT_EQ(plan_two_->GetLocalBytesUsed(), 100 * kBytesPerMegabyte); |
| 1137 EXPECT_EQ(plan_two_->GetTotalBytesUsed(), 100 * kBytesPerMegabyte); |
| 1138 EXPECT_FALSE(plan_two_->IsActive()); |
| 1139 EXPECT_EQ(plan_three_->GetDataBytesMax(), 100 * kBytesPerMegabyte); |
| 1140 EXPECT_EQ(plan_three_->GetDataBytesUsed(), 0); |
| 1141 EXPECT_EQ(plan_three_->GetLocalBytesUsed(), 100 * kBytesPerMegabyte); |
| 1142 EXPECT_EQ(plan_three_->GetTotalBytesUsed(), 100 * kBytesPerMegabyte); |
| 1143 EXPECT_FALSE(plan_three_->IsActive()); |
| 1144 } |
| 1145 |
| 1146 // three plans, usage consumes first, consumes second, consumes third w/ overage |
| 1147 TEST_F(DataPlanTest, ThreePlansThirdConsumedWithOverage) { |
| 1148 DataPlanList data_plans; |
| 1149 data_plans.push_back(plan_one_); |
| 1150 data_plans.push_back(plan_two_); |
| 1151 data_plans.push_back(plan_three_); |
| 1152 |
| 1153 // set up mock expectations and method return values |
| 1154 { |
| 1155 testing::InSequence expect_calls_in_order; |
| 1156 EXPECT_CALL(device_mock_, ByteCounterRunning()) |
| 1157 .WillRepeatedly(testing::Return(true)); |
| 1158 EXPECT_CALL(service_manager_mock_, |
| 1159 OnDataPlanInactive(testing::Ref(service_mock_), |
| 1160 testing::Ref(*plan_one_))).Times(1); |
| 1161 EXPECT_CALL(device_mock_, ResetByteCounter(210 * kBytesPerMegabyte, |
| 1162 0)).Times(1); |
| 1163 EXPECT_CALL(service_manager_mock_, |
| 1164 OnDataPlanInactive(testing::Ref(service_mock_), |
| 1165 testing::Ref(*plan_two_))).Times(1); |
| 1166 EXPECT_CALL(device_mock_, ResetByteCounter(110 * kBytesPerMegabyte, |
| 1167 0)).Times(1); |
| 1168 EXPECT_CALL(service_manager_mock_, |
| 1169 OnDataPlanInactive(testing::Ref(service_mock_), |
| 1170 testing::Ref(*plan_three_))).Times(1); |
| 1171 EXPECT_CALL(device_mock_, ResetByteCounter(10 * kBytesPerMegabyte, |
| 1172 0)).Times(1); |
| 1173 EXPECT_CALL(device_mock_, StopByteCounter()).Times(1); |
| 1174 } |
| 1175 |
| 1176 // simulate a byte counter update |
| 1177 uint64 rx_bytes = 155 * kBytesPerMegabyte; |
| 1178 uint64 tx_bytes = 155 * kBytesPerMegabyte; |
| 1179 bool result = DataPlan::OnByteCounterUpdate(&data_plans, &service_mock_, |
| 1180 &service_manager_mock_, |
| 1181 &device_mock_, rx_bytes, |
| 1182 tx_bytes); |
| 1183 |
| 1184 // check if test passed |
| 1185 EXPECT_TRUE(result); |
| 1186 EXPECT_EQ(plan_one_->GetDataBytesMax(), 100 * kBytesPerMegabyte); |
| 1187 EXPECT_EQ(plan_one_->GetDataBytesUsed(), 0); |
| 1188 EXPECT_EQ(plan_one_->GetLocalBytesUsed(), 100 * kBytesPerMegabyte); |
| 1189 EXPECT_EQ(plan_one_->GetTotalBytesUsed(), 100 * kBytesPerMegabyte); |
| 1190 EXPECT_FALSE(plan_one_->IsActive()); |
| 1191 EXPECT_EQ(plan_two_->GetDataBytesMax(), 100 * kBytesPerMegabyte); |
| 1192 EXPECT_EQ(plan_two_->GetDataBytesUsed(), 0); |
| 1193 EXPECT_EQ(plan_two_->GetLocalBytesUsed(), 100 * kBytesPerMegabyte); |
| 1194 EXPECT_EQ(plan_two_->GetTotalBytesUsed(), 100 * kBytesPerMegabyte); |
| 1195 EXPECT_FALSE(plan_two_->IsActive()); |
| 1196 EXPECT_EQ(plan_three_->GetDataBytesMax(), 100 * kBytesPerMegabyte); |
| 1197 EXPECT_EQ(plan_three_->GetDataBytesUsed(), 0); |
| 1198 EXPECT_EQ(plan_three_->GetLocalBytesUsed(), 100 * kBytesPerMegabyte); |
| 1199 EXPECT_EQ(plan_three_->GetTotalBytesUsed(), 100 * kBytesPerMegabyte); |
| 1200 EXPECT_FALSE(plan_three_->IsActive()); |
| 1201 } |
| 1202 |
442 } // namespace cashew | 1203 } // namespace cashew |
OLD | NEW |