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

Unified Diff: remoting/host/json_host_config_unittest.cc

Issue 10007048: Cleanup and simplify HostConfig and JsonHostConfig. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/host/json_host_config.cc ('k') | remoting/host/plugin/daemon_controller_mac.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/json_host_config_unittest.cc
diff --git a/remoting/host/json_host_config_unittest.cc b/remoting/host/json_host_config_unittest.cc
index 3184f75bfc85e372b7396bc2680ac06c7e0132a1..6f52b7e42f701862295a735fff8856848c3af122 100644
--- a/remoting/host/json_host_config_unittest.cc
+++ b/remoting/host/json_host_config_unittest.cc
@@ -4,8 +4,6 @@
#include "base/file_util.h"
#include "base/memory/ref_counted.h"
-#include "base/message_loop.h"
-#include "base/message_loop_proxy.h"
#include "base/path_service.h"
#include "base/scoped_temp_dir.h"
#include "remoting/host/json_host_config.h"
@@ -26,51 +24,42 @@ const char* kTestConfig =
class JsonHostConfigTest : public testing::Test {
protected:
- virtual void SetUp() {
- message_loop_proxy_ = base::MessageLoopProxy::current();
- }
-
static void WriteTestFile(const FilePath& filename) {
file_util::WriteFile(filename, kTestConfig, std::strlen(kTestConfig));
}
// The temporary directory used to contain the test operations.
ScopedTempDir test_dir_;
- // A message loop that we can use as the file thread message loop.
- MessageLoop message_loop_;
- scoped_refptr<base::MessageLoopProxy> message_loop_proxy_;
};
TEST_F(JsonHostConfigTest, InvalidFile) {
ASSERT_TRUE(test_dir_.CreateUniqueTempDir());
FilePath non_existent_file =
test_dir_.path().AppendASCII("non_existent.json");
- scoped_refptr<JsonHostConfig> target(
- new JsonHostConfig(non_existent_file, message_loop_proxy_.get()));
- EXPECT_FALSE(target->Read());
+ JsonHostConfig target(non_existent_file);
+ EXPECT_FALSE(target.Read());
}
TEST_F(JsonHostConfigTest, Read) {
ASSERT_TRUE(test_dir_.CreateUniqueTempDir());
FilePath test_file = test_dir_.path().AppendASCII("read.json");
WriteTestFile(test_file);
- scoped_refptr<JsonHostConfig> target(
- new JsonHostConfig(test_file, message_loop_proxy_.get()));
- ASSERT_TRUE(target->Read());
+ JsonHostConfig target(test_file);
+ ASSERT_TRUE(target.Read());
std::string value;
- EXPECT_TRUE(target->GetString(kXmppLoginConfigPath, &value));
+ EXPECT_TRUE(target.GetString(kXmppLoginConfigPath, &value));
EXPECT_EQ("test@gmail.com", value);
- EXPECT_TRUE(target->GetString(kXmppAuthTokenConfigPath, &value));
+ EXPECT_TRUE(target.GetString(kXmppAuthTokenConfigPath, &value));
EXPECT_EQ("TEST_AUTH_TOKEN", value);
- EXPECT_TRUE(target->GetString(kHostIdConfigPath, &value));
+ EXPECT_TRUE(target.GetString(kHostIdConfigPath, &value));
EXPECT_EQ("TEST_HOST_ID", value);
- EXPECT_TRUE(target->GetString(kHostNameConfigPath, &value));
+ EXPECT_TRUE(target.GetString(kHostNameConfigPath, &value));
EXPECT_EQ("TEST_MACHINE_NAME", value);
- EXPECT_TRUE(target->GetString(kPrivateKeyConfigPath, &value));
+ EXPECT_TRUE(target.GetString(kPrivateKeyConfigPath, &value));
EXPECT_EQ("TEST_PRIVATE_KEY", value);
- EXPECT_FALSE(target->GetString("non_existent_value", &value));
+ EXPECT_FALSE(target.GetString("non_existent_value", &value));
}
TEST_F(JsonHostConfigTest, Write) {
@@ -78,32 +67,27 @@ TEST_F(JsonHostConfigTest, Write) {
FilePath test_file = test_dir_.path().AppendASCII("write.json");
WriteTestFile(test_file);
- scoped_refptr<JsonHostConfig> target(
- new JsonHostConfig(test_file, message_loop_proxy_.get()));
- ASSERT_TRUE(target->Read());
+ JsonHostConfig target(test_file);
+ ASSERT_TRUE(target.Read());
std::string new_auth_token_value = "NEW_AUTH_TOKEN";
- target->SetString(kXmppAuthTokenConfigPath, new_auth_token_value);
- target->Save();
-
- message_loop_.RunAllPending();
+ target.SetString(kXmppAuthTokenConfigPath, new_auth_token_value);
+ ASSERT_TRUE(target.Save());
// Now read the file again and check that the value has been written.
- scoped_refptr<JsonHostConfig> reader(
- new JsonHostConfig(test_file, message_loop_proxy_.get()));
-
- ASSERT_TRUE(reader->Read());
+ JsonHostConfig reader(test_file);
+ ASSERT_TRUE(reader.Read());
std::string value;
- EXPECT_TRUE(reader->GetString(kXmppLoginConfigPath, &value));
+ EXPECT_TRUE(reader.GetString(kXmppLoginConfigPath, &value));
EXPECT_EQ("test@gmail.com", value);
- EXPECT_TRUE(reader->GetString(kXmppAuthTokenConfigPath, &value));
+ EXPECT_TRUE(reader.GetString(kXmppAuthTokenConfigPath, &value));
EXPECT_EQ(new_auth_token_value, value);
- EXPECT_TRUE(reader->GetString(kHostIdConfigPath, &value));
+ EXPECT_TRUE(reader.GetString(kHostIdConfigPath, &value));
EXPECT_EQ("TEST_HOST_ID", value);
- EXPECT_TRUE(reader->GetString(kHostNameConfigPath, &value));
+ EXPECT_TRUE(reader.GetString(kHostNameConfigPath, &value));
EXPECT_EQ("TEST_MACHINE_NAME", value);
- EXPECT_TRUE(reader->GetString(kPrivateKeyConfigPath, &value));
+ EXPECT_TRUE(reader.GetString(kPrivateKeyConfigPath, &value));
EXPECT_EQ("TEST_PRIVATE_KEY", value);
}
« no previous file with comments | « remoting/host/json_host_config.cc ('k') | remoting/host/plugin/daemon_controller_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698