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

Unified Diff: chrome/browser/chromeos/network_message_observer_unittest.cc

Issue 6347044: Only show notification for low 3g data for the last data-based plan.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/chromeos/network_message_observer.cc ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/network_message_observer_unittest.cc
===================================================================
--- chrome/browser/chromeos/network_message_observer_unittest.cc (revision 0)
+++ chrome/browser/chromeos/network_message_observer_unittest.cc (revision 0)
@@ -0,0 +1,80 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/chromeos/network_message_observer.h"
+
+#include "base/time.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace chromeos {
+
+namespace {
+
+CellularDataPlan CreateDataPlan(CellularDataPlanType type, int64 start_sec,
+ int64 end_sec, int64 bytes, int64 used) {
+ CellularDataPlan plan;
+ plan.plan_type = type;
+ plan.plan_start_time = base::Time::FromDoubleT(start_sec);
+ plan.plan_end_time = base::Time::FromDoubleT(end_sec);
+ plan.plan_data_bytes = bytes;
+ plan.data_bytes_used = used;
+ return plan;
+}
+
+} // namespace
+
+// Test the code that checks if a data plan is an applicable backup plan.
+TEST(NetworkMessageObserverTest, TestIsApplicableBackupPlan) {
+ // IsApplicableBackupPlan returns true if:
+ // (unlimited OR used bytes < max bytes) AND
+ // ((start time - 1 sec) <= end time of currently active plan).
+
+ // Current plan that ends at 100.
+ CellularDataPlan plan =
+ CreateDataPlan(CELLULAR_DATA_PLAN_UNLIMITED, 0, 100, 0, 0);
+
+ // Test unlimited plans.
+ CellularDataPlan time_50 =
+ CreateDataPlan(CELLULAR_DATA_PLAN_UNLIMITED, 50, 500, 0, 0);
+ CellularDataPlan time_100 =
+ CreateDataPlan(CELLULAR_DATA_PLAN_UNLIMITED, 100, 500, 0, 0);
+ CellularDataPlan time_101 =
+ CreateDataPlan(CELLULAR_DATA_PLAN_UNLIMITED, 101, 500, 0, 0);
+ CellularDataPlan time_102 =
+ CreateDataPlan(CELLULAR_DATA_PLAN_UNLIMITED, 102, 500, 0, 0);
+ EXPECT_TRUE(NetworkMessageObserver::IsApplicableBackupPlan(&plan, &time_50));
+ EXPECT_TRUE(NetworkMessageObserver::IsApplicableBackupPlan(&plan, &time_100));
+ EXPECT_TRUE(NetworkMessageObserver::IsApplicableBackupPlan(&plan, &time_101));
+ EXPECT_FALSE(NetworkMessageObserver::IsApplicableBackupPlan(&plan,
+ &time_102));
+
+ // Test data plans.
+ CellularDataPlan data_0_0 =
+ CreateDataPlan(CELLULAR_DATA_PLAN_METERED_PAID, 100, 500, 0, 0);
+ CellularDataPlan data_100_0 =
+ CreateDataPlan(CELLULAR_DATA_PLAN_METERED_PAID, 100, 500, 100, 0);
+ CellularDataPlan data_100_50 =
+ CreateDataPlan(CELLULAR_DATA_PLAN_METERED_PAID, 100, 500, 100, 50);
+ CellularDataPlan data_100_100 =
+ CreateDataPlan(CELLULAR_DATA_PLAN_METERED_PAID, 100, 500, 100, 100);
+ CellularDataPlan data_100_200 =
+ CreateDataPlan(CELLULAR_DATA_PLAN_METERED_PAID, 100, 500, 100, 200);
+ CellularDataPlan data_100_0_gap =
+ CreateDataPlan(CELLULAR_DATA_PLAN_METERED_PAID, 200, 500, 100, 0);
+ EXPECT_FALSE(NetworkMessageObserver::IsApplicableBackupPlan(&plan,
+ &data_0_0));
+ EXPECT_TRUE(NetworkMessageObserver::IsApplicableBackupPlan(&plan,
+ &data_100_0));
+ EXPECT_TRUE(NetworkMessageObserver::IsApplicableBackupPlan(&plan,
+ &data_100_50));
+ EXPECT_FALSE(NetworkMessageObserver::IsApplicableBackupPlan(&plan,
+ &data_100_100));
+ EXPECT_FALSE(NetworkMessageObserver::IsApplicableBackupPlan(&plan,
+ &data_100_200));
+ EXPECT_FALSE(NetworkMessageObserver::IsApplicableBackupPlan(&plan,
+ &data_100_0_gap));
+}
+
+
+} // namespace chromeos
Property changes on: chrome/browser/chromeos/network_message_observer_unittest.cc
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « chrome/browser/chromeos/network_message_observer.cc ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698