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.
5 #include "base/prefs/pref_service.h"
6 #include "chrome/browser/extensions/extension_apitest.h"
7 #include "chrome/browser/profiles/profile.h"
8 #include "chrome/browser/ui/browser.h"
9 #include "chrome/common/pref_names.h"
11 #if defined(OS_CHROMEOS)
12 #include "chromeos/dbus/dbus_thread_manager.h"
13 #include "chromeos/dbus/fake_update_engine_client.h"
15 using chromeos::UpdateEngineClient
;
18 IN_PROC_BROWSER_TEST_F(ExtensionApiTest
, GetIncognitoModeAvailability
) {
19 PrefService
* pref_service
= browser()->profile()->GetPrefs();
20 pref_service
->SetInteger(prefs::kIncognitoModeAvailability
, 1);
22 EXPECT_TRUE(RunComponentExtensionTest(
23 "system/get_incognito_mode_availability")) << message_
;
26 #if defined(OS_CHROMEOS)
28 class GetUpdateStatusApiTest
: public ExtensionApiTest
{
30 GetUpdateStatusApiTest() : fake_update_engine_client_(NULL
) {}
32 void SetUpInProcessBrowserTestFixture() override
{
33 ExtensionApiTest::SetUpInProcessBrowserTestFixture();
34 fake_update_engine_client_
= new chromeos::FakeUpdateEngineClient
;
35 chromeos::DBusThreadManager::GetSetterForTesting()->SetUpdateEngineClient(
36 scoped_ptr
<UpdateEngineClient
>(fake_update_engine_client_
));
39 void TearDownInProcessBrowserTestFixture() override
{
40 ExtensionApiTest::TearDownInProcessBrowserTestFixture();
44 chromeos::FakeUpdateEngineClient
* fake_update_engine_client_
;
47 DISALLOW_COPY_AND_ASSIGN(GetUpdateStatusApiTest
);
50 IN_PROC_BROWSER_TEST_F(GetUpdateStatusApiTest
, Progress
) {
51 UpdateEngineClient::Status status_not_available
;
52 status_not_available
.status
= UpdateEngineClient::UPDATE_STATUS_IDLE
;
53 UpdateEngineClient::Status status_updating
;
54 status_updating
.status
= UpdateEngineClient::UPDATE_STATUS_DOWNLOADING
;
55 status_updating
.download_progress
= 0.5;
56 UpdateEngineClient::Status status_boot_needed
;
57 status_boot_needed
.status
=
58 UpdateEngineClient::UPDATE_STATUS_UPDATED_NEED_REBOOT
;
60 // The fake client returns the last status in this order.
61 fake_update_engine_client_
->PushLastStatus(status_not_available
);
62 fake_update_engine_client_
->PushLastStatus(status_updating
);
63 fake_update_engine_client_
->PushLastStatus(status_boot_needed
);
65 ASSERT_TRUE(RunComponentExtensionTest(
66 "system/get_update_status")) << message_
;