Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / chromeos / power / peripheral_battery_observer_browsertest.cc
index 8d93dbf..904ae8a 100644 (file)
@@ -8,6 +8,7 @@
 #include "base/message_loop/message_loop.h"
 #include "chrome/browser/browser_process.h"
 #include "chrome/browser/notifications/notification_ui_manager.h"
+#include "chrome/browser/profiles/profile_manager.h"
 #include "chrome/test/base/in_process_browser_test.h"
 #include "chromeos/dbus/dbus_thread_manager.h"
 #include "content/public/test/test_utils.h"
@@ -34,23 +35,23 @@ class PeripheralBatteryObserverTest : public InProcessBrowserTest {
   PeripheralBatteryObserverTest() {}
   virtual ~PeripheralBatteryObserverTest() {}
 
-  virtual void SetUp() OVERRIDE {
+  virtual void SetUp() override {
     chromeos::DBusThreadManager::Initialize();
   }
 
-  virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
+  virtual void SetUpInProcessBrowserTestFixture() override {
     InProcessBrowserTest::SetUpInProcessBrowserTestFixture();
   }
 
-  virtual void SetUpOnMainThread() OVERRIDE {
+  virtual void SetUpOnMainThread() override {
     observer_.reset(new PeripheralBatteryObserver());
   }
 
-  virtual void TearDownOnMainThread() OVERRIDE {
+  virtual void TearDownOnMainThread() override {
     observer_.reset();
   }
 
-  virtual void TearDownInProcessBrowserTestFixture() OVERRIDE {
+  virtual void TearDownInProcessBrowserTestFixture() override {
     InProcessBrowserTest::TearDownInProcessBrowserTestFixture();
   }
 
@@ -80,7 +81,10 @@ IN_PROC_BROWSER_TEST_F(PeripheralBatteryObserverTest, Basic) {
   EXPECT_EQ(info.name, kTestDeviceName);
   EXPECT_EQ(info.level, 50);
   EXPECT_EQ(info.last_notification_timestamp, base::TimeTicks());
-  EXPECT_FALSE(notification_manager->FindById(kTestBatteryAddress) != NULL);
+  EXPECT_FALSE(notification_manager->FindById(
+                   kTestBatteryAddress,
+                   NotificationUIManager::GetProfileID(
+                       ProfileManager::GetPrimaryUserProfile())) != NULL);
 
   // Level 5 at time 110, low-battery notification.
   clock.Advance(base::TimeDelta::FromSeconds(10));
@@ -88,7 +92,10 @@ IN_PROC_BROWSER_TEST_F(PeripheralBatteryObserverTest, Basic) {
                                              kTestDeviceName, 5);
   EXPECT_EQ(info.level, 5);
   EXPECT_EQ(info.last_notification_timestamp, clock.NowTicks());
-  EXPECT_TRUE(notification_manager->FindById(kTestBatteryAddress) != NULL);
+  EXPECT_TRUE(notification_manager->FindById(
+                  kTestBatteryAddress,
+                  NotificationUIManager::GetProfileID(
+                      ProfileManager::GetPrimaryUserProfile())) != NULL);
 
   // Level -1 at time 115, cancel previous notification
   clock.Advance(base::TimeDelta::FromSeconds(5));
@@ -97,7 +104,10 @@ IN_PROC_BROWSER_TEST_F(PeripheralBatteryObserverTest, Basic) {
   EXPECT_EQ(info.level, 5);
   EXPECT_EQ(info.last_notification_timestamp,
             clock.NowTicks() - base::TimeDelta::FromSeconds(5));
-  EXPECT_FALSE(notification_manager->FindById(kTestBatteryAddress) != NULL);
+  EXPECT_FALSE(notification_manager->FindById(
+                   kTestBatteryAddress,
+                   NotificationUIManager::GetProfileID(
+                       ProfileManager::GetPrimaryUserProfile())) != NULL);
 
   // Level 50 at time 120, no low-battery notification.
   clock.Advance(base::TimeDelta::FromSeconds(5));
@@ -106,7 +116,10 @@ IN_PROC_BROWSER_TEST_F(PeripheralBatteryObserverTest, Basic) {
   EXPECT_EQ(info.level, 50);
   EXPECT_EQ(info.last_notification_timestamp,
             clock.NowTicks() - base::TimeDelta::FromSeconds(10));
-  EXPECT_FALSE(notification_manager->FindById(kTestBatteryAddress) != NULL);
+  EXPECT_FALSE(notification_manager->FindById(
+                   kTestBatteryAddress,
+                   NotificationUIManager::GetProfileID(
+                       ProfileManager::GetPrimaryUserProfile())) != NULL);
 
   // Level 5 at time 130, no low-battery notification (throttling).
   clock.Advance(base::TimeDelta::FromSeconds(10));
@@ -115,7 +128,10 @@ IN_PROC_BROWSER_TEST_F(PeripheralBatteryObserverTest, Basic) {
   EXPECT_EQ(info.level, 5);
   EXPECT_EQ(info.last_notification_timestamp,
             clock.NowTicks() - base::TimeDelta::FromSeconds(20));
-  EXPECT_FALSE(notification_manager->FindById(kTestBatteryAddress) != NULL);
+  EXPECT_FALSE(notification_manager->FindById(
+                   kTestBatteryAddress,
+                   NotificationUIManager::GetProfileID(
+                       ProfileManager::GetPrimaryUserProfile())) != NULL);
 }
 
 IN_PROC_BROWSER_TEST_F(PeripheralBatteryObserverTest, InvalidBatteryInfo) {
@@ -147,10 +163,16 @@ IN_PROC_BROWSER_TEST_F(PeripheralBatteryObserverTest, DeviceRemove) {
   observer_->PeripheralBatteryStatusReceived(kTestBatteryPath,
                                              kTestDeviceName, 5);
   EXPECT_EQ(observer_->batteries_.count(kTestBatteryAddress), 1u);
-  EXPECT_TRUE(notification_manager->FindById(kTestBatteryAddress) != NULL);
+  EXPECT_TRUE(notification_manager->FindById(
+                  kTestBatteryAddress,
+                  NotificationUIManager::GetProfileID(
+                      ProfileManager::GetPrimaryUserProfile())) != NULL);
 
   observer_->RemoveBattery(kTestBatteryAddress);
-  EXPECT_FALSE(notification_manager->FindById(kTestBatteryAddress) != NULL);
+  EXPECT_FALSE(notification_manager->FindById(
+                   kTestBatteryAddress,
+                   NotificationUIManager::GetProfileID(
+                       ProfileManager::GetPrimaryUserProfile())) != NULL);
 }
 
 }  // namespace chromeos