| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/extensions/extension_apitest.h" | |
| 6 #include "chrome/browser/prefs/pref_service.h" | |
| 7 #include "chrome/browser/profiles/profile.h" | |
| 8 #include "chrome/browser/ui/browser.h" | |
| 9 #include "chrome/common/pref_names.h" | |
| 10 | |
| 11 #if defined(OS_CHROMEOS) | |
| 12 #include "chromeos/dbus/mock_dbus_thread_manager.h" | |
| 13 #include "chromeos/dbus/mock_update_engine_client.h" | |
| 14 | |
| 15 using chromeos::UpdateEngineClient; | |
| 16 using ::testing::Return; | |
| 17 #endif | |
| 18 | |
| 19 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, GetIncognitoModeAvailability) { | |
| 20 PrefService* pref_service = browser()->profile()->GetPrefs(); | |
| 21 pref_service->SetInteger(prefs::kIncognitoModeAvailability, 1); | |
| 22 | |
| 23 EXPECT_TRUE(RunComponentExtensionTest( | |
| 24 "system/get_incognito_mode_availability")) << message_; | |
| 25 } | |
| 26 | |
| 27 #if defined(OS_CHROMEOS) | |
| 28 | |
| 29 class GetUpdateStatusApiTest : public ExtensionApiTest { | |
| 30 public: | |
| 31 GetUpdateStatusApiTest() : mock_update_engine_client_(NULL) {} | |
| 32 | |
| 33 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | |
| 34 ExtensionApiTest::SetUpInProcessBrowserTestFixture(); | |
| 35 chromeos::MockDBusThreadManager* mock_dbus_thread_manager = | |
| 36 new chromeos::MockDBusThreadManager; | |
| 37 chromeos::DBusThreadManager::InitializeForTesting(mock_dbus_thread_manager); | |
| 38 mock_update_engine_client_ = | |
| 39 mock_dbus_thread_manager->mock_update_engine_client(); | |
| 40 } | |
| 41 | |
| 42 virtual void TearDownInProcessBrowserTestFixture() OVERRIDE { | |
| 43 chromeos::DBusThreadManager::Shutdown(); | |
| 44 ExtensionApiTest::TearDownInProcessBrowserTestFixture(); | |
| 45 } | |
| 46 | |
| 47 protected: | |
| 48 chromeos::MockUpdateEngineClient* mock_update_engine_client_; | |
| 49 | |
| 50 private: | |
| 51 DISALLOW_COPY_AND_ASSIGN(GetUpdateStatusApiTest); | |
| 52 }; | |
| 53 | |
| 54 IN_PROC_BROWSER_TEST_F(GetUpdateStatusApiTest, Progress) { | |
| 55 UpdateEngineClient::Status status_not_available; | |
| 56 status_not_available.status = UpdateEngineClient::UPDATE_STATUS_IDLE; | |
| 57 UpdateEngineClient::Status status_updating; | |
| 58 status_updating.status = UpdateEngineClient::UPDATE_STATUS_DOWNLOADING; | |
| 59 status_updating.download_progress = 0.5; | |
| 60 UpdateEngineClient::Status status_boot_needed; | |
| 61 status_boot_needed.status = | |
| 62 UpdateEngineClient::UPDATE_STATUS_UPDATED_NEED_REBOOT; | |
| 63 | |
| 64 EXPECT_CALL(*mock_update_engine_client_, GetLastStatus()) | |
| 65 .WillOnce(Return(status_not_available)) | |
| 66 .WillOnce(Return(status_updating)) | |
| 67 .WillOnce(Return(status_boot_needed)); | |
| 68 ASSERT_TRUE(RunComponentExtensionTest( | |
| 69 "system/get_update_status")) << message_; | |
| 70 } | |
| 71 | |
| 72 #endif | |
| OLD | NEW |