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

Side by Side Diff: chrome/browser/extensions/system/system_apitest.cc

Issue 8747003: Add private system extension API to get system update status (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix for the case with no update on non-ChromeOS platforms Created 9 years 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/extensions/extension_apitest.h" 5 #include "chrome/browser/extensions/extension_apitest.h"
6 #include "chrome/browser/prefs/pref_service.h" 6 #include "chrome/browser/prefs/pref_service.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 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, SystemApi) { 11 #if defined(OS_CHROMEOS)
12 #include "chrome/browser/chromeos/dbus/mock_dbus_thread_manager.h"
13 #include "chrome/browser/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) {
12 PrefService* pref_service = browser()->profile()->GetPrefs(); 20 PrefService* pref_service = browser()->profile()->GetPrefs();
13 pref_service->SetInteger(prefs::kIncognitoModeAvailability, 1); 21 pref_service->SetInteger(prefs::kIncognitoModeAvailability, 1);
14 22
15 EXPECT_TRUE(RunComponentExtensionTest("system")) << message_; 23 EXPECT_TRUE(RunComponentExtensionTest(
24 "system/get_incognito_mode_availability")) << message_;
16 } 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
OLDNEW
« no previous file with comments | « chrome/browser/extensions/system/system_api.cc ('k') | chrome/common/extensions/api/extension_api.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698