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

Side by Side Diff: chrome/browser/chromeos/extensions/active_tab_permission_granter_delegate_chromeos_unittest.cc

Issue 2907493002: ChromeOS: Per-user time zone: refactor tests first. (Closed)
Patch Set: Fix debug build Created 3 years, 6 months 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
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/chromeos/extensions/active_tab_permission_granter_deleg ate_chromeos.h" 5 #include "chrome/browser/chromeos/extensions/active_tab_permission_granter_deleg ate_chromeos.h"
6 6
7 #include <memory>
7 #include <string> 8 #include <string>
8 9
9 #include "base/run_loop.h" 10 #include "base/run_loop.h"
10 #include "chrome/browser/chromeos/extensions/public_session_permission_helper.h" 11 #include "chrome/browser/chromeos/extensions/public_session_permission_helper.h"
11 #include "chrome/test/base/chrome_render_view_host_test_harness.h" 12 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
12 #include "chromeos/login/scoped_test_public_session_login_state.h" 13 #include "chromeos/login/scoped_test_public_session_login_state.h"
13 #include "extensions/browser/extension_dialog_auto_confirm.h" 14 #include "extensions/browser/extension_dialog_auto_confirm.h"
14 #include "extensions/common/extension.h" 15 #include "extensions/common/extension.h"
15 #include "extensions/common/extension_builder.h" 16 #include "extensions/common/extension_builder.h"
16 #include "extensions/common/value_builder.h" 17 #include "extensions/common/value_builder.h"
(...skipping 17 matching lines...) Expand all
34 35
35 } // namespace 36 } // namespace
36 37
37 class ActiveTabPermissionGranterDelegateChromeOSTest 38 class ActiveTabPermissionGranterDelegateChromeOSTest
38 : public ChromeRenderViewHostTestHarness { 39 : public ChromeRenderViewHostTestHarness {
39 protected: 40 protected:
40 void SetUp() override; 41 void SetUp() override;
41 void TearDown() override; 42 void TearDown() override;
42 43
43 ActiveTabPermissionGranterDelegateChromeOS delegate_; 44 ActiveTabPermissionGranterDelegateChromeOS delegate_;
44 chromeos::ScopedTestPublicSessionLoginState login_state_; 45 std::unique_ptr<chromeos::ScopedTestPublicSessionLoginState> login_state_;
45 }; 46 };
46 47
47 void ActiveTabPermissionGranterDelegateChromeOSTest::SetUp() { 48 void ActiveTabPermissionGranterDelegateChromeOSTest::SetUp() {
48 ChromeRenderViewHostTestHarness::SetUp(); 49 ChromeRenderViewHostTestHarness::SetUp();
50 login_state_.reset(new chromeos::ScopedTestPublicSessionLoginState());
49 } 51 }
50 52
51 void ActiveTabPermissionGranterDelegateChromeOSTest::TearDown() { 53 void ActiveTabPermissionGranterDelegateChromeOSTest::TearDown() {
54 login_state_.reset();
52 permission_helper::ResetPermissionsForTesting(); 55 permission_helper::ResetPermissionsForTesting();
53 ChromeRenderViewHostTestHarness::TearDown(); 56 ChromeRenderViewHostTestHarness::TearDown();
54 } 57 }
55 58
56 TEST_F(ActiveTabPermissionGranterDelegateChromeOSTest, GrantedForWhitelisted) { 59 TEST_F(ActiveTabPermissionGranterDelegateChromeOSTest, GrantedForWhitelisted) {
57 auto extension = CreateExtension(kWhitelistedId); 60 auto extension = CreateExtension(kWhitelistedId);
58 EXPECT_TRUE(delegate_.ShouldGrantActiveTab(extension.get(), nullptr)); 61 EXPECT_TRUE(delegate_.ShouldGrantActiveTab(extension.get(), nullptr));
59 } 62 }
60 63
61 TEST_F(ActiveTabPermissionGranterDelegateChromeOSTest, 64 TEST_F(ActiveTabPermissionGranterDelegateChromeOSTest,
(...skipping 14 matching lines...) Expand all
76 auto extension = CreateExtension(kNonWhitelistedId); 79 auto extension = CreateExtension(kNonWhitelistedId);
77 // Allow the permission request. 80 // Allow the permission request.
78 ScopedTestDialogAutoConfirm auto_confirm(ScopedTestDialogAutoConfirm::ACCEPT); 81 ScopedTestDialogAutoConfirm auto_confirm(ScopedTestDialogAutoConfirm::ACCEPT);
79 EXPECT_FALSE(delegate_.ShouldGrantActiveTab(extension.get(), nullptr)); 82 EXPECT_FALSE(delegate_.ShouldGrantActiveTab(extension.get(), nullptr));
80 base::RunLoop().RunUntilIdle(); 83 base::RunLoop().RunUntilIdle();
81 // The permission request is granted now. 84 // The permission request is granted now.
82 EXPECT_TRUE(delegate_.ShouldGrantActiveTab(extension.get(), nullptr)); 85 EXPECT_TRUE(delegate_.ShouldGrantActiveTab(extension.get(), nullptr));
83 } 86 }
84 87
85 } // namespace extensions 88 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698