core: Merge the fake runtime into the fake profile.

People need to be able to refer to the fake runtimes methods, that is
the whole point of the fake runtime.  However runtime implementations are
moving into internal.  There was no need to separate the fake runtime
from the fake profile, so I have just merged the packages.

Change-Id: I95927a30c72df11dc6d9ca5ae8fbd35194ab9ed6
diff --git a/profiles/fake/runtime.go b/profiles/fake/runtime.go
new file mode 100644
index 0000000..19640e5
--- /dev/null
+++ b/profiles/fake/runtime.go
@@ -0,0 +1,65 @@
+// fake implements a fake runtime.  The fake runtime is useful in tests when you
+// want to mock out important components.
+// TODO(mattr): Make a more complete, but still fake, implementation.
+package fake
+
+import (
+	"v.io/v23"
+	"v.io/v23/context"
+	"v.io/v23/security"
+
+	tsecurity "v.io/core/veyron/lib/testutil/security"
+)
+
+type contextKey int
+
+const (
+	clientKey = contextKey(iota)
+	principalKey
+	loggerKey
+	backgroundKey
+)
+
+type Runtime struct{}
+
+func new(ctx *context.T) (*Runtime, *context.T, v23.Shutdown, error) {
+	ctx = context.WithValue(ctx, principalKey, tsecurity.NewPrincipal())
+	return &Runtime{}, ctx, func() {}, nil
+}
+
+func (r *Runtime) Init(ctx *context.T) error {
+	return nil
+}
+
+func (r *Runtime) SetPrincipal(ctx *context.T, principal security.Principal) (*context.T, error) {
+	return context.WithValue(ctx, principalKey, principal), nil
+}
+
+func (r *Runtime) GetPrincipal(ctx *context.T) security.Principal {
+	p, _ := ctx.Value(principalKey).(security.Principal)
+	return p
+}
+
+func (r *Runtime) GetAppCycle(ctx *context.T) v23.AppCycle {
+	panic("unimplemented")
+}
+
+func (r *Runtime) SetBackgroundContext(ctx *context.T) *context.T {
+	// Note we add an extra context with a nil value here.
+	// This prevents users from travelling back through the
+	// chain of background contexts.
+	ctx = context.WithValue(ctx, backgroundKey, nil)
+	return context.WithValue(ctx, backgroundKey, ctx)
+}
+
+func (r *Runtime) GetBackgroundContext(ctx *context.T) *context.T {
+	bctx, _ := ctx.Value(backgroundKey).(*context.T)
+	if bctx == nil {
+		// There should always be a background context.  If we don't find
+		// it, that means that the user passed us the background context
+		// in hopes of following the chain.  Instead we just give them
+		// back what they sent in, which is correct.
+		return ctx
+	}
+	return bctx
+}