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

Side by Side Diff: remoting/test/app_remoting_test_driver_environment_unittest.cc

Issue 1237883002: Added chromoting test environment for the tests to share data. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added unittest, display connection stats ability, and error check for transition delay. Created 5 years, 5 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
« no previous file with comments | « remoting/test/BUILD.gn ('k') | remoting/test/chromoting_test_driver_environment.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "remoting/test/app_remoting_test_driver_environment.h" 5 #include "remoting/test/app_remoting_test_driver_environment.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "remoting/test/fake_access_token_fetcher.h" 10 #include "remoting/test/fake_access_token_fetcher.h"
11 #include "remoting/test/fake_app_remoting_report_issue_request.h" 11 #include "remoting/test/fake_app_remoting_report_issue_request.h"
12 #include "remoting/test/fake_refresh_token_store.h"
12 #include "remoting/test/fake_remote_host_info_fetcher.h" 13 #include "remoting/test/fake_remote_host_info_fetcher.h"
13 #include "remoting/test/mock_access_token_fetcher.h" 14 #include "remoting/test/mock_access_token_fetcher.h"
14 #include "remoting/test/refresh_token_store.h" 15 #include "remoting/test/refresh_token_store.h"
15 #include "testing/gmock/include/gmock/gmock.h" 16 #include "testing/gmock/include/gmock/gmock.h"
16 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
17 18
18 namespace { 19 namespace {
19 const char kAuthCodeValue[] = "4/892379827345jkefvkdfbv"; 20 const char kAuthCodeValue[] = "4/892379827345jkefvkdfbv";
20 const char kRefreshTokenValue[] = "1/lkjalseLKJlsiJgr45jbv";
21 const char kUserNameValue[] = "remoting_user@gmail.com"; 21 const char kUserNameValue[] = "remoting_user@gmail.com";
22 const char kTestApplicationId[] = "sadlkjlsjgadjfgoajdfgagb"; 22 const char kTestApplicationId[] = "sadlkjlsjgadjfgoajdfgagb";
23 const char kAnotherTestApplicationId[] = "waklgoisdhfnvjkdsfbljn"; 23 const char kAnotherTestApplicationId[] = "waklgoisdhfnvjkdsfbljn";
24 const char kTestHostId1[] = "awesome_test_host_id"; 24 const char kTestHostId1[] = "awesome_test_host_id";
25 const char kTestHostId2[] = "super_awesome_test_host_id"; 25 const char kTestHostId2[] = "super_awesome_test_host_id";
26 const char kTestHostId3[] = "uber_awesome_test_host_id"; 26 const char kTestHostId3[] = "uber_awesome_test_host_id";
27 } 27 }
28 28
29 namespace remoting { 29 namespace remoting {
30 namespace test { 30 namespace test {
31 31
32 using testing::_; 32 using testing::_;
33 33
34 // Stubs out the file API and returns fake data so we can remove
35 // file system dependencies when testing the TestDriverEnvironment.
36 class FakeRefreshTokenStore : public RefreshTokenStore {
37 public:
38 FakeRefreshTokenStore();
39 ~FakeRefreshTokenStore() override;
40
41 // RefreshTokenStore interface.
42 std::string FetchRefreshToken() override;
43 bool StoreRefreshToken(const std::string& refresh_token) override;
44
45 bool refresh_token_write_attempted() const {
46 return refresh_token_write_attempted_;
47 }
48
49 const std::string& stored_refresh_token_value() const {
50 return stored_refresh_token_value_;
51 }
52
53 void set_refresh_token_value(const std::string& new_token_value) {
54 refresh_token_value_ = new_token_value;
55 }
56
57 void set_refresh_token_write_succeeded(bool write_succeeded) {
58 refresh_token_write_succeeded_ = write_succeeded;
59 }
60
61 private:
62 // Control members used to return specific data to the caller.
63 std::string refresh_token_value_;
64 bool refresh_token_write_succeeded_;
65
66 // Verification members to observe the value of the data being written.
67 bool refresh_token_write_attempted_;
68 std::string stored_refresh_token_value_;
69
70 DISALLOW_COPY_AND_ASSIGN(FakeRefreshTokenStore);
71 };
72
73 FakeRefreshTokenStore::FakeRefreshTokenStore()
74 : refresh_token_value_(kRefreshTokenValue),
75 refresh_token_write_succeeded_(true),
76 refresh_token_write_attempted_(false) {
77 }
78
79 FakeRefreshTokenStore::~FakeRefreshTokenStore() {
80 }
81
82 std::string FakeRefreshTokenStore::FetchRefreshToken() {
83 return refresh_token_value_;
84 }
85
86 bool FakeRefreshTokenStore::StoreRefreshToken(
87 const std::string& refresh_token) {
88 // Record the information passed to us to write.
89 refresh_token_write_attempted_ = true;
90 stored_refresh_token_value_ = refresh_token;
91
92 return refresh_token_write_succeeded_;
93 }
94
95 class AppRemotingTestDriverEnvironmentTest : public ::testing::Test { 34 class AppRemotingTestDriverEnvironmentTest : public ::testing::Test {
96 public: 35 public:
97 AppRemotingTestDriverEnvironmentTest(); 36 AppRemotingTestDriverEnvironmentTest();
98 ~AppRemotingTestDriverEnvironmentTest() override; 37 ~AppRemotingTestDriverEnvironmentTest() override;
99 38
100 FakeAccessTokenFetcher* fake_access_token_fetcher() const { 39 FakeAccessTokenFetcher* fake_access_token_fetcher() const {
101 return fake_access_token_fetcher_; 40 return fake_access_token_fetcher_;
102 } 41 }
103 42
104 protected: 43 protected:
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 std::sort(expected_host_list.begin(), expected_host_list.end()); 461 std::sort(expected_host_list.begin(), expected_host_list.end());
523 462
524 EXPECT_EQ(actual_host_list.size(), expected_host_list.size()); 463 EXPECT_EQ(actual_host_list.size(), expected_host_list.size());
525 for (size_t i = 0; i < actual_host_list.size(); ++i) { 464 for (size_t i = 0; i < actual_host_list.size(); ++i) {
526 EXPECT_EQ(actual_host_list[i], expected_host_list[i]); 465 EXPECT_EQ(actual_host_list[i], expected_host_list[i]);
527 } 466 }
528 } 467 }
529 468
530 } // namespace test 469 } // namespace test
531 } // namespace remoting 470 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/test/BUILD.gn ('k') | remoting/test/chromoting_test_driver_environment.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698