Chromium Code Reviews| 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 #include "base/prefs/pref_service.h" | 5 #include "base/prefs/pref_service.h" |
| 6 #include "chrome/browser/extensions/extension_apitest.h" | 6 #include "chrome/browser/extensions/extension_apitest.h" |
| 7 #include "chrome/browser/profiles/profile.h" | 7 #include "chrome/browser/profiles/profile.h" |
| 8 #include "chrome/browser/ui/browser.h" | 8 #include "chrome/browser/ui/browser.h" |
| 9 #include "chrome/common/pref_names.h" | 9 #include "chrome/common/pref_names.h" |
| 10 | 10 |
| 11 #if defined(OS_CHROMEOS) | 11 #if defined(OS_CHROMEOS) |
| 12 #include "chromeos/dbus/mock_dbus_thread_manager.h" | 12 #include "chromeos/dbus/fake_update_engine_client.h" |
| 13 #include "chromeos/dbus/mock_update_engine_client.h" | 13 #include "chromeos/dbus/mock_dbus_thread_manager_without_gmock.h" |
| 14 | 14 |
| 15 using chromeos::UpdateEngineClient; | 15 using chromeos::UpdateEngineClient; |
| 16 using ::testing::Return; | |
| 17 #endif | 16 #endif |
| 18 | 17 |
| 19 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, GetIncognitoModeAvailability) { | 18 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, GetIncognitoModeAvailability) { |
| 20 PrefService* pref_service = browser()->profile()->GetPrefs(); | 19 PrefService* pref_service = browser()->profile()->GetPrefs(); |
| 21 pref_service->SetInteger(prefs::kIncognitoModeAvailability, 1); | 20 pref_service->SetInteger(prefs::kIncognitoModeAvailability, 1); |
| 22 | 21 |
| 23 EXPECT_TRUE(RunComponentExtensionTest( | 22 EXPECT_TRUE(RunComponentExtensionTest( |
| 24 "system/get_incognito_mode_availability")) << message_; | 23 "system/get_incognito_mode_availability")) << message_; |
| 25 } | 24 } |
| 26 | 25 |
| 27 #if defined(OS_CHROMEOS) | 26 #if defined(OS_CHROMEOS) |
| 28 | 27 |
| 29 class GetUpdateStatusApiTest : public ExtensionApiTest { | 28 class GetUpdateStatusApiTest : public ExtensionApiTest { |
| 30 public: | 29 public: |
| 31 GetUpdateStatusApiTest() : mock_update_engine_client_(NULL) {} | 30 GetUpdateStatusApiTest() : fake_update_engine_client_(NULL) {} |
| 32 | 31 |
| 33 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 32 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { |
| 34 ExtensionApiTest::SetUpInProcessBrowserTestFixture(); | 33 ExtensionApiTest::SetUpInProcessBrowserTestFixture(); |
| 35 chromeos::MockDBusThreadManager* mock_dbus_thread_manager = | 34 chromeos::MockDBusThreadManagerWithoutGMock* mock_dbus_thread_manager = |
| 36 new chromeos::MockDBusThreadManager; | 35 new chromeos::MockDBusThreadManagerWithoutGMock; |
| 37 chromeos::DBusThreadManager::InitializeForTesting(mock_dbus_thread_manager); | 36 chromeos::DBusThreadManager::InitializeForTesting(mock_dbus_thread_manager); |
| 38 mock_update_engine_client_ = | 37 fake_update_engine_client_ = |
| 39 mock_dbus_thread_manager->mock_update_engine_client(); | 38 mock_dbus_thread_manager->fake_update_engine_client(); |
| 40 EXPECT_CALL(*mock_update_engine_client_, GetLastStatus()) | |
| 41 .Times(1) | |
|
bartfab (slow)
2013/05/14 09:35:06
This used to verify that the method gets called ex
hashimoto
2013/05/14 10:37:21
Do we need to check that GetLastStatus() is called
bartfab (slow)
2013/05/14 10:53:14
Fair enough. Let's leave out the check.
Haruki Sato
2013/05/14 13:20:14
Thank you guys for the review!
| |
| 42 .WillOnce(Return(chromeos::MockUpdateEngineClient::Status())); | |
| 43 } | 39 } |
| 44 | 40 |
| 45 virtual void TearDownInProcessBrowserTestFixture() OVERRIDE { | 41 virtual void TearDownInProcessBrowserTestFixture() OVERRIDE { |
| 46 chromeos::DBusThreadManager::Shutdown(); | 42 chromeos::DBusThreadManager::Shutdown(); |
| 47 ExtensionApiTest::TearDownInProcessBrowserTestFixture(); | 43 ExtensionApiTest::TearDownInProcessBrowserTestFixture(); |
| 48 } | 44 } |
| 49 | 45 |
| 50 protected: | 46 protected: |
| 51 chromeos::MockUpdateEngineClient* mock_update_engine_client_; | 47 chromeos::FakeUpdateEngineClient* fake_update_engine_client_; |
| 52 | 48 |
| 53 private: | 49 private: |
| 54 DISALLOW_COPY_AND_ASSIGN(GetUpdateStatusApiTest); | 50 DISALLOW_COPY_AND_ASSIGN(GetUpdateStatusApiTest); |
| 55 }; | 51 }; |
| 56 | 52 |
| 57 IN_PROC_BROWSER_TEST_F(GetUpdateStatusApiTest, Progress) { | 53 IN_PROC_BROWSER_TEST_F(GetUpdateStatusApiTest, Progress) { |
| 58 UpdateEngineClient::Status status_not_available; | 54 UpdateEngineClient::Status status_not_available; |
| 59 status_not_available.status = UpdateEngineClient::UPDATE_STATUS_IDLE; | 55 status_not_available.status = UpdateEngineClient::UPDATE_STATUS_IDLE; |
| 60 UpdateEngineClient::Status status_updating; | 56 UpdateEngineClient::Status status_updating; |
| 61 status_updating.status = UpdateEngineClient::UPDATE_STATUS_DOWNLOADING; | 57 status_updating.status = UpdateEngineClient::UPDATE_STATUS_DOWNLOADING; |
| 62 status_updating.download_progress = 0.5; | 58 status_updating.download_progress = 0.5; |
| 63 UpdateEngineClient::Status status_boot_needed; | 59 UpdateEngineClient::Status status_boot_needed; |
| 64 status_boot_needed.status = | 60 status_boot_needed.status = |
| 65 UpdateEngineClient::UPDATE_STATUS_UPDATED_NEED_REBOOT; | 61 UpdateEngineClient::UPDATE_STATUS_UPDATED_NEED_REBOOT; |
| 66 | 62 |
| 67 EXPECT_CALL(*mock_update_engine_client_, GetLastStatus()) | 63 // The fake client returns the last status in this order. |
| 68 .WillOnce(Return(status_not_available)) | 64 fake_update_engine_client_->PushLastStatus(status_not_available); |
| 69 .WillOnce(Return(status_updating)) | 65 fake_update_engine_client_->PushLastStatus(status_updating); |
| 70 .WillOnce(Return(status_boot_needed)); | 66 fake_update_engine_client_->PushLastStatus(status_boot_needed); |
| 67 | |
| 71 ASSERT_TRUE(RunComponentExtensionTest( | 68 ASSERT_TRUE(RunComponentExtensionTest( |
| 72 "system/get_update_status")) << message_; | 69 "system/get_update_status")) << message_; |
| 73 } | 70 } |
| 74 | 71 |
| 75 #endif | 72 #endif |
| OLD | NEW |